Skip to content

Add swift package add-target-dependency command to edit the manifest #7594

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

Conversation

DougGregor
Copy link
Member

@DougGregor DougGregor commented May 25, 2024

Introduce a command to add a new dependency to a target in the manifest file, exposing the newly-added API to the command line. Here's the help output:

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.

Introduce a command to add a new dependency to a target in the manifest
file, exposing the newly-added API to the command line. Here's the
help output:

    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.
@DougGregor
Copy link
Member Author

@swift-ci please test

@rauhul
Copy link
Member

rauhul commented May 25, 2024

Would this be more natural as:

swift package target add-dependency ...

which could live parallel to API like:

swift package target init <name> [--type <executable, target, module>]
swift package target rename <name> <new-name>
swift package target remove-dependency ...

@DougGregor
Copy link
Member Author

Would this be more natural as:

swift package target add-dependency ...

which could live parallel to API like:

swift package target init <name> [--type <executable, target, module>]
swift package target rename <name> <new-name>
swift package target remove-dependency ...

According to SE-0301, there was some discussion of having this "fourth level" of command when that proposal was reviewed, and we decided against it then. But maybe with us adding more of these commands now, it's worth re-opening the discussion.

@rauhul
Copy link
Member

rauhul commented May 25, 2024

According to SE-0301, there was some discussion of having this "fourth level" of command when that proposal was reviewed, and we decided against it then. But maybe with us adding more of these commands now, it's worth re-opening the discussion.

👍 That SE is so old I had entirely forgotten about it. It's probably worth revisiting the names in a future proposal.

@DougGregor
Copy link
Member Author

I put up a pitch thread at https://forums.swift.org/t/package-manifest-editing-commands-beyond-se-0301/72085 to discuss

@DougGregor
Copy link
Member Author

👍 That SE is so old I had entirely forgotten about it. It's probably worth revisiting the names in a future proposal.

I reimplemented all of it almost exactly before learning about it. Whoops!

@DougGregor DougGregor merged commit 15ac439 into swiftlang:main Jun 3, 2024
5 checks passed
@DougGregor DougGregor deleted the package-add-target-dependency branch June 3, 2024 18:30
DougGregor added a commit to DougGregor/swift-package-manager that referenced this pull request Jun 3, 2024
swiftlang#7594)

Introduce a command to add a new dependency to a target in the manifest
file, exposing the newly-added API to the command line. Here's the help
output:

    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.

(cherry picked from commit 15ac439)
DougGregor added a commit that referenced this pull request Jun 4, 2024
…anifest (#7628)

**Explanation**: Building on SE-0301, add a new command `swift package
add-target-dependency` to edit the package manifest and add a new
dependency to a given target.
**Original** PR:
#7594
**Risk**: Low. New, very simple code path to edit the package manifest
in a narrow way.
**Reviewed by**: @MaxDesiatov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants