Skip to content

Conversation

@jakobhellermann
Copy link
Contributor

@jakobhellermann jakobhellermann commented Nov 5, 2025

What does this PR try to resolve?

Add dynamic completions for the various -p <package> arguments.

Fixes #15004

cargo bench|build|check|doc|fix|test -p <tab>`
cargo package|publish -p <tab>
cargo add|pkgid|remove|report|run|rustc|rustdoc -p <tab>

cargo uninstall -p <tab>
cargo tree -p <tab> -i <tab>
cargo clean -p <tab> # not implemented

Supersedes #14553 and #15338


EDIT: the second implementation has been chosen

In the first commit I implemented the different completions for different usages by splitting the arg_package methods into multiple ones if necessary:

     * arg_package_spec
     * arg_package_spec_no_all
     * arg_installed_package_spec_no_all <- new (for cargo uninstall)
     * arg_dependency_package_spec_no_all <- new (for cargo tree)
     * arg_clean_package_spec_simple <- new (for cargo clean)
     * arg_package_spec_simple
     * arg_package

In the second commit I tried to instead pass an ArgValueCandidates into the function to prevent that duplication.

     * arg_package_spec
     * arg_package_spec_no_all (ArgValueCandidates)
     * arg_package_spec_simple (ArgValueCandidates)
     * arg_package

I think I have a small preference towards the latter, but no strong opinion.

@rustbot
Copy link
Collaborator

rustbot commented Nov 5, 2025

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-cli Area: Command-line interface, option parsing, etc. Command-clean Command-package Command-publish Command-tree Command-uninstall S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 5, 2025
@epage
Copy link
Contributor

epage commented Nov 5, 2025

I think I have a small preference towards the latter, but no strong opinion.

I much prefer the second.

@jakobhellermann jakobhellermann force-pushed the package-dynamic-completion branch from c3f74fd to 355f966 Compare November 6, 2025 10:17
@epage
Copy link
Contributor

epage commented Nov 6, 2025

Feel free to clean up your commits to represent how they should be merged, rather than based on review feedback. We have guidance on atomic commits at https://doc.crates.io/contrib/process/working-on-cargo.html#submitting-a-pull-request

@epage
Copy link
Contributor

epage commented Nov 6, 2025

Just some small stylstic changes and this should be good to go, thanks!

@jakobhellermann jakobhellermann force-pushed the package-dynamic-completion branch from c2aebcd to fcaf35d Compare November 6, 2025 14:22
@jakobhellermann jakobhellermann force-pushed the package-dynamic-completion branch from fcaf35d to 0819035 Compare November 6, 2025 14:22
@jakobhellermann
Copy link
Contributor Author

Feel free to clean up your commits to represent how they should be merged, rather than based on review feedback. We have guidance on atomic commits at https://doc.crates.io/contrib/process/working-on-cargo.html#submitting-a-pull-request

Yes, that was my intention with the force push after the first round of review feedback. But yea, the c2aebcd could be part of the first commit as well.

@epage epage enabled auto-merge November 6, 2025 14:33
@epage epage added this pull request to the merge queue Nov 6, 2025
Merged via the queue into rust-lang:master with commit 88c0fba Nov 6, 2025
25 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 6, 2025
@jakobhellermann jakobhellermann deleted the package-dynamic-completion branch November 6, 2025 15:29
bors added a commit to rust-lang/rust that referenced this pull request Nov 8, 2025
Update cargo submodule

22 commits in 6368002885a04cbeae39a82cf5118f941559a40a..445fe4a68f469bf936b2fd81de2c503b233a7f4f
2025-10-31 14:31:52 +0000 to 2025-11-07 18:08:19 +0000
- fix(depinfo): prevent invalid trailing backslash on Windows (rust-lang/cargo#16223)
- refactor: Remove lazycell (rust-lang/cargo#16224)
- refactor: extract ConfigValue to its own module (rust-lang/cargo#16222)
- fix(config): non-mergeable list from cli should take priority (rust-lang/cargo#16220)
- fix(compile): build.warnings=deny shouldn't block hard warnings (rust-lang/cargo#16213)
- fix: display absolute path in the `missing in PATH` warning (rust-lang/cargo#16125)
- fix: non-mergeable list from config cli merge the same way  (rust-lang/cargo#16219)
- docs(contrib): Link out to rustc diagnostic style guide (rust-lang/cargo#16216)
- fix: Remove build-plan (rust-lang/cargo#16212)
- Add native completions for `--package` on various commands (rust-lang/cargo#16210)
- fix(completions): don't wrap completion item help in parenthesis (rust-lang/cargo#16215)
- refactor(locking): Make disabling locking on NFS mounts explicit (rust-lang/cargo#16177)
- docs(unstable): Move compile-time-deps out of Stabilized section (rust-lang/cargo#16211)
- docs(ref): Rename DEP_NAME_KEY to DEP_LINKS_KEY (rust-lang/cargo#16205)
- feat(build-analysis): emit rebuild reason log entry (rust-lang/cargo#16203)
- chore: Update dependencies (rust-lang/cargo#16200)
- chore(deps): update cargo-semver-checks to v0.45.0 (rust-lang/cargo#16190)
- chore(deps): update msrv (rust-lang/cargo#16178)
- refactor: embed deserialize validation logic in ProgressConfig (rust-lang/cargo#16194)
- refactor(gctx): extract config schema to a module (rust-lang/cargo#16195)
- chore: bump to 0.94.0; update changelog (rust-lang/cargo#16191)
- chore(deps): update rust crate gix to 0.74.0 (rust-lang/cargo#16186)

r? ghost
@rustbot rustbot added this to the 1.93.0 milestone Nov 8, 2025
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Nov 10, 2025
Update cargo submodule

22 commits in 6368002885a04cbeae39a82cf5118f941559a40a..445fe4a68f469bf936b2fd81de2c503b233a7f4f
2025-10-31 14:31:52 +0000 to 2025-11-07 18:08:19 +0000
- fix(depinfo): prevent invalid trailing backslash on Windows (rust-lang/cargo#16223)
- refactor: Remove lazycell (rust-lang/cargo#16224)
- refactor: extract ConfigValue to its own module (rust-lang/cargo#16222)
- fix(config): non-mergeable list from cli should take priority (rust-lang/cargo#16220)
- fix(compile): build.warnings=deny shouldn't block hard warnings (rust-lang/cargo#16213)
- fix: display absolute path in the `missing in PATH` warning (rust-lang/cargo#16125)
- fix: non-mergeable list from config cli merge the same way  (rust-lang/cargo#16219)
- docs(contrib): Link out to rustc diagnostic style guide (rust-lang/cargo#16216)
- fix: Remove build-plan (rust-lang/cargo#16212)
- Add native completions for `--package` on various commands (rust-lang/cargo#16210)
- fix(completions): don't wrap completion item help in parenthesis (rust-lang/cargo#16215)
- refactor(locking): Make disabling locking on NFS mounts explicit (rust-lang/cargo#16177)
- docs(unstable): Move compile-time-deps out of Stabilized section (rust-lang/cargo#16211)
- docs(ref): Rename DEP_NAME_KEY to DEP_LINKS_KEY (rust-lang/cargo#16205)
- feat(build-analysis): emit rebuild reason log entry (rust-lang/cargo#16203)
- chore: Update dependencies (rust-lang/cargo#16200)
- chore(deps): update cargo-semver-checks to v0.45.0 (rust-lang/cargo#16190)
- chore(deps): update msrv (rust-lang/cargo#16178)
- refactor: embed deserialize validation logic in ProgressConfig (rust-lang/cargo#16194)
- refactor(gctx): extract config schema to a module (rust-lang/cargo#16195)
- chore: bump to 0.94.0; update changelog (rust-lang/cargo#16191)
- chore(deps): update rust crate gix to 0.74.0 (rust-lang/cargo#16186)

r? ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cli suggestions for --package

4 participants