Skip to content

update plugin argument parsing so that execution arguments can be passed after command plugin name #6128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 11, 2023

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented Feb 7, 2023

motivation: improve usability of command plugins

changes: re-parse the arguments that are passed after the plugin name and merge the relevant options before running the command plugin

this allows invocation like swift package <plugin> --disable-sandbox (instead of the lest intuitive swift package --disable-sandbox <plugin>

@tomerd
Copy link
Contributor Author

tomerd commented Feb 7, 2023

cc @natecook1000

@tomerd
Copy link
Contributor Author

tomerd commented Feb 7, 2023

@swift-ci smoke test

@tomerd tomerd self-assigned this Feb 7, 2023
@neonichu
Copy link
Contributor

neonichu commented Feb 8, 2023

With #6114, we have one more plugin option now.

@tomerd tomerd force-pushed the fix/plugin-argument branch from 212993e to 93008f9 Compare February 8, 2023 01:20
// At this point we know we found exactly one command plugin, so we run it.
try PluginCommand.run(
plugin: matchingPlugins[0],
package: packageGraph.rootPackages[0],
packageGraph: packageGraph,
options: pluginOptions,
arguments: Array( remaining.dropFirst()),
swiftTool: swiftTool)
arguments: pluginArguments.remaining,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want to keep passing the same Array(remaining.dropFirst()) arguments to the plugin, since the new approach is going to strip out anything that matches a swift package flag or option. Like --verbose could get eaten up during the re-parsing even if it has been making its way to the plugin.

…sed after command plugin name

motivaiton: improve usability of command plugins

changes:
* re-parse the arguments that are passed after the plugin name and merge the relevant options before running the command plugin
@tomerd tomerd force-pushed the fix/plugin-argument branch from 93008f9 to 309345d Compare February 8, 2023 23:52
@tomerd
Copy link
Contributor Author

tomerd commented Feb 8, 2023

@swift-ci smoke test

@tomerd
Copy link
Contributor Author

tomerd commented Feb 8, 2023

@neonichu @natecook1000 this should be ready

// List the available plugins, if asked to.
if listCommands {
let packageGraph = try swiftTool.loadPackageGraph()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@tomerd tomerd force-pushed the fix/plugin-argument branch from 309345d to 0c65684 Compare February 9, 2023 00:57
@tomerd
Copy link
Contributor Author

tomerd commented Feb 9, 2023

@swift-ci smoke test

@tomerd tomerd enabled auto-merge (squash) February 9, 2023 00:58
@tomerd
Copy link
Contributor Author

tomerd commented Feb 10, 2023

@swift-ci smoke test

1 similar comment
@tomerd
Copy link
Contributor Author

tomerd commented Feb 11, 2023

@swift-ci smoke test

@tomerd tomerd merged commit fec4bcf into swiftlang:main Feb 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants