swiftlang/swift-package-manager

`swift package add-plugin`

Opened this issue · 3 comments

Description

A simple swift package add-plugin command to add build plugins to targets.
Similar to the new swift package add-target etc... commands.

Use case: https://arc.net/l/quote/vmglmkzj

Agreed. I'd love to be able to fully create a package manifest from the command line.

@dschaefer2 I took a crack at this last night. Do you think this is something I need to write a official proposal for?

For this specific example of adding a plugin to an existing target as mentioned in the attached use case.

Should somehow be able to add plugins (The OpenAPI Generator plugin) to those targets as well?

it would actually mirror swift package add-target-dependency not swift package add-target.

Proposed interface:

> swift package add-target-plugin --help
OVERVIEW: Add a new target plugin to the manifest

USAGE: swift package add-target-plugin <plugin-name> <target-name> [--package <package>]

ARGUMENTS:
  <plugin-name>           The name of the new plugin
  <target-name>           The name of the target to update

OPTIONS:
  --package <package>     The package in which the plugin resides
  --version               Show the version.
  -h, -help, --help       Show help information.

which is similar to add-target-dependency:

> swift package add-target-dependency --help
OVERVIEW: Add a new target dependency to the manifest

USAGE: swift package add-target-dependency <dependency-name> <target-name> [--package <package>]

ARGUMENTS:
  <dependency-name>       The name of the new dependency
  <target-name>           The name of the target to update

OPTIONS:
  --package <package>     The package in which the dependency resides
  --version               Show the version.
  -h, -help, --help       Show help information.

I think it would be good to write up a forum post to request for comment at least. It's important to get community feedback whenever we add official commands and options to swiftpm. Not sure this one would be controversial but it's a good habit for us to get into.

And thanks!