Hi everyone!
SE-0301 "Package editing commands" was accepted a while ago, but the implementation never managed to land. I went ahead and implemented the three commands it specifies:
swift package add-product
swift package add-target
swift package add-dependency
Now, it didn't take very long for me to want to add another command to edit package manifests, and adding new specific editing commands is really easy. I have a PR up for swift package add-target-dependency
, which adds a new dependency to a named target. The command-line interface I have is this:
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.
It's getting a little bit crowded in the swift package
command space. Here's the full list from main
:
SUBCOMMANDS:
add-dependency Add a package dependency to the manifest
add-product Add a new product to the manifest
add-target Add a new target to the manifest
add-target-dependency Add a new target dependency to the manifest
clean Delete build artifacts
purge-cache Purge the global repository cache.
reset Reset the complete cache/build directory
update Update package dependencies
describe Describe the current package
init Initialize a new package
experimental-install Offers the ability to install executable products of
the current package.
experimental-uninstall Offers the ability to uninstall executable products
previously installed by `swift package
experimental-install`.
diagnose-api-breaking-changes
Diagnose API-breaking changes to Swift modules in a
package
dump-symbol-graph Dump Symbol Graph
dump-package Print parsed Package.swift as JSON
edit Put a package in editable mode
unedit Remove a package from editable mode
config Manipulate configuration of the package
resolve Resolve package dependencies
show-dependencies Print the resolved dependency graph
tools-version Manipulate tools version of the current package
compute-checksum Compute the checksum for a binary artifact.
archive-source Create a source archive for the package
completion-command Completion command (for shell completions)
plugin Invoke a command plugin or perform other actions on
command plugins
It seems likely that we'll want to add more of these in the future. Should we continue to add them as subcommands of swift package
, or should we revisit the decision noted in the Alternatives Considered in SE-0301?
I could imagine two groupings that would make sense here:
swift package manifest <command>
, which all of the manifest-editing commands go under.swift package product <command>
andswift package target <command>
for product- and target-specific commands, some of which are manifest editing.
Thoughts?
Doug