Skip to content

Unify argument formatting for add setting and migrate #8800

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

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Jun 10, 2025

Motivation:

The inconsistency in argument formatting came up as part of SE-0486 review. This is the first step in a direction to make command formatting more consistent.

  • swift package migrate:

    • Rename --targets to --target
    • Change --target and --to-feature to accept space separated argument lists
  • swift package -add-setting:

    • Switch to .upToNextOption formatting. Instead of --swift A=B --swift C=D switch to --swift A=B C=D.

Modifications:

  • Update MigrateOptions to use .upToNextOption for targets and features.
  • Update SwiftPackageCommand's _swiftSettings option to use .upToNextOption

Result:

The swift package migrate and swift package add-setting command line is now shorter and has consistent formatting.

Resolves: rdar://152687586

xedin added 2 commits June 10, 2025 08:53
- Rename `--targets` to `--target`
- Change `--target` and `--to-feature` to accept space separated argument lists
Instead of `--swift A=B --swift C=D` switch to `--swift A=B C=D`
to make the command shorter and consistent with `migrate` and
in the future other commands.
@xedin
Copy link
Contributor Author

xedin commented Jun 10, 2025

@swift-ci please test

Copy link
Contributor

@bnbarham bnbarham left a comment

Choose a reason for hiding this comment

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

Nice 🥳

@xedin xedin merged commit d1a9dc3 into swiftlang:main Jun 10, 2025
6 checks passed
xedin added a commit that referenced this pull request Jun 12, 2025
…commands (#8812)

Cherry-pick of
#8800,
#8806

### Motivation:

Fixes for the following problems:

- Sometimes if the previous build was unsuccessful subsequent `swift
package migrate` invocation fails with `error: did not compute a build
plan yet`.
- Implicitly generated targets (currently only test targets) are
included in migration which results in extraneous warnings and failures
(i.e. to update the manifest).

The inconsistency in argument formatting came up as part of SE-0486
review. This is the first step in a direction to make command formatting
more consistent.

- `swift package migrate`:
  - Rename `--targets` to `--target`
- Change `--target` and `--to-feature` to accept space separated
argument lists

- `swift package -add-setting`:
- Switch to `.upToNextOption` formatting. Instead of `--swift A=B
--swift C=D` switch to `--swift A=B C=D`.

### Modifications:

- Update `Migrate` command's `createBuildSystem` API to avoid build
manifest caching. That ensures that features in migration mode are never
persistent and requires a fresh build plan which avoid issues with
previous builds.
- Make it possible to mark a `Module` as `implicit` i.e. when it's a
synthesized/discovered test target or a system module.
- Update `Migrate` command to filter `implicit` modules when no targets
are specified by the user.
- Update `MigrateOptions` to use `.upToNextOption` for targets and
features.
- Update `SwiftPackageCommand`'s `_swiftSettings` option to use
`.upToNextOption`

### Result:

`swift package migrate` is made more stable with fewer unactionable
warnings and errors and the command line is now shorter and has
consistent formatting.

Resolves: rdar://152687586
Resolves: rdar://152689053
Resolves: rdar://152687084
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