Skip to content
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

feat: Add native comlpetion with CompleteEnv under the nightly #14493

Merged
merged 3 commits into from
Sep 10, 2024

Conversation

shannmu
Copy link
Contributor

@shannmu shannmu commented Sep 4, 2024

What does this PR try to resolve?

Related issue #6645
Tracking issue #14520
This PR is the first step to move cargo shell completions to native completions by using clap_complete crate. It makes users could complete cargo subcommand and flags.

By using clap_complete crate, we could extend the supported shells to Bash, Zsh, Elvish, Fish, and PowerShell. However, at the current stage, the support for PowerShell in clap_complete is not fully developed.
See clap-rs/clap#3166 to get more context about what features clap_complete has supported.

How to test and review this PR?

  1. Build a test environment, including the necessary short completion scripts, and the complete function to start an interactive shell with the help of a pty device and obtain completion results.
  2. Simply test the completion results of subcommands in bash, zsh, fish, elvish.

@rustbot
Copy link
Collaborator

rustbot commented Sep 4, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added A-cli Area: Command-line interface, option parsing, etc. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 4, 2024
Cargo.toml Outdated Show resolved Hide resolved
@epage epage changed the title feat: Switch hand-written completions to native completions feat: Add nightly support for native completions Sep 4, 2024
@epage epage changed the title feat: Add nightly support for native completions feat: Add native comlpetion with CompleteEnv under the nightly Sep 4, 2024
tests/testsuite/main.rs Outdated Show resolved Hide resolved
@epage
Copy link
Contributor

epage commented Sep 9, 2024

Also, it looks like you need to git rebase against the latest master; there is a merge conflict.

@epage
Copy link
Contributor

epage commented Sep 9, 2024

Looks like there is a doc and a test failure (besides windows)

@shannmu shannmu force-pushed the dynamic_switch branch 2 times, most recently from 063df78 to dc240d6 Compare September 9, 2024 16:36
@shannmu shannmu force-pushed the dynamic_switch branch 2 times, most recently from 7a1a235 to 0f08b56 Compare September 10, 2024 05:48
@rustbot rustbot added the A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. label Sep 10, 2024
@shannmu shannmu force-pushed the dynamic_switch branch 3 times, most recently from 8804390 to 40cfe93 Compare September 10, 2024 07:45
@shannmu
Copy link
Contributor Author

shannmu commented Sep 10, 2024

On macOS, the test code for bash, fish, and elvish cannot pass. The default shell in macOS CI seems to be zsh, and only zsh works correctly. So I added cfg!(target_os = "macos") branch for these tests.

@epage
Copy link
Contributor

epage commented Sep 10, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Sep 10, 2024

📌 Commit 7b0b977 has been approved by epage

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 10, 2024
@bors
Copy link
Contributor

bors commented Sep 10, 2024

⌛ Testing commit 7b0b977 with merge e7ca9be...

@bors
Copy link
Contributor

bors commented Sep 10, 2024

☀️ Test successful - checks-actions
Approved by: epage
Pushing e7ca9be to master...

@bors bors merged commit e7ca9be into rust-lang:master Sep 10, 2024
24 checks passed
@ehuss
Copy link
Contributor

ehuss commented Sep 13, 2024

Hi @shannmu! There seems to be a problem with this PR that I can't quite figure out. The shell_completions::fish test seems to be failing. See this CI run for example. The error looks like it is only emitting cargo ∅.

I am able to reproduce on my system (I am unable to get it to pass at all). I can't tell how this PR was able to pass CI, so maybe there is some flakiness with it? Do you think you can investigate?

And FYI, cargo's CI is currently broken for other reasons (see rust-lang/rust#130291), but that only affects a subset of CI jobs.

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 15, 2024
Update cargo

24 commits in c1fa840a85eca53818895901a53fae34247448b2..468f1500bdca6591555b204ef31f92d725053190
2024-08-29 21:03:53 +0000 to 2024-09-14 19:24:54 +0000
- Disable the shell_completions tests (rust-lang/cargo#14546)
- fix(vendor): trust crate version only when coming from registries (rust-lang/cargo#14530)
- docs: Feature resolver version 2: clarify use of 'target' (rust-lang/cargo#14540)
- Update docs for how cargo is published (rust-lang/cargo#14539)
- feat: Add native comlpetion with CompleteEnv under the nightly (rust-lang/cargo#14493)
- fix(new): Add to workspace relative to manifest, not current-dir (rust-lang/cargo#14505)
- Fix parsing of comma separated values in --crate-type flag (rust-lang/cargo#14499)
- Include public/private dependency status in `cargo metadata` (rust-lang/cargo#14504)
- Remove unnecessary symbols (rust-lang/cargo#14519)
- docs: bin source can be `src/main.rs` and/or in `src/bin/` (rust-lang/cargo#14515)
- fix(toml): Don't require MSRV bump for pub/priv (rust-lang/cargo#14507)
- bail before packaging on same version (rust-lang/cargo#14448)
- Implement path-bases (RFC 3529) 2/n: `cargo [add|remove|update]` support (rust-lang/cargo#14427)
- Publish workspace (rust-lang/cargo#14433)
- Bump ci's version of cargo-semver-version (rust-lang/cargo#14503)
- Document -Zpackage-workspace (rust-lang/cargo#14496)
- uplift windows gnullvm import libraries (rust-lang/cargo#14451)
- Bump to 0.84.0; update changelog (rust-lang/cargo#14495)
- Fix cargo add behaving different when translating package name (rust-lang/cargo#13765)
- chore(deps): update rust crate core-foundation to 0.10.0 (rust-lang/cargo#14475)
- feat(resolve): Report MSRV compatible version instead of incomptible (rust-lang/cargo#14471)
- Don't automatically include the current crate when packaging (rust-lang/cargo#14488)
- Fix elided lifetime (rust-lang/cargo#14487)
- chore(deps): update rust crate pasetors to 0.7.0 (rust-lang/cargo#14478)

r? ghost
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 15, 2024
Update cargo

24 commits in c1fa840a85eca53818895901a53fae34247448b2..468f1500bdca6591555b204ef31f92d725053190
2024-08-29 21:03:53 +0000 to 2024-09-14 19:24:54 +0000
- Disable the shell_completions tests (rust-lang/cargo#14546)
- fix(vendor): trust crate version only when coming from registries (rust-lang/cargo#14530)
- docs: Feature resolver version 2: clarify use of 'target' (rust-lang/cargo#14540)
- Update docs for how cargo is published (rust-lang/cargo#14539)
- feat: Add native comlpetion with CompleteEnv under the nightly (rust-lang/cargo#14493)
- fix(new): Add to workspace relative to manifest, not current-dir (rust-lang/cargo#14505)
- Fix parsing of comma separated values in --crate-type flag (rust-lang/cargo#14499)
- Include public/private dependency status in `cargo metadata` (rust-lang/cargo#14504)
- Remove unnecessary symbols (rust-lang/cargo#14519)
- docs: bin source can be `src/main.rs` and/or in `src/bin/` (rust-lang/cargo#14515)
- fix(toml): Don't require MSRV bump for pub/priv (rust-lang/cargo#14507)
- bail before packaging on same version (rust-lang/cargo#14448)
- Implement path-bases (RFC 3529) 2/n: `cargo [add|remove|update]` support (rust-lang/cargo#14427)
- Publish workspace (rust-lang/cargo#14433)
- Bump ci's version of cargo-semver-version (rust-lang/cargo#14503)
- Document -Zpackage-workspace (rust-lang/cargo#14496)
- uplift windows gnullvm import libraries (rust-lang/cargo#14451)
- Bump to 0.84.0; update changelog (rust-lang/cargo#14495)
- Fix cargo add behaving different when translating package name (rust-lang/cargo#13765)
- chore(deps): update rust crate core-foundation to 0.10.0 (rust-lang/cargo#14475)
- feat(resolve): Report MSRV compatible version instead of incomptible (rust-lang/cargo#14471)
- Don't automatically include the current crate when packaging (rust-lang/cargo#14488)
- Fix elided lifetime (rust-lang/cargo#14487)
- chore(deps): update rust crate pasetors to 0.7.0 (rust-lang/cargo#14478)

r? ghost
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 16, 2024
Update cargo

25 commits in c1fa840a85eca53818895901a53fae34247448b2..a9a418d1a22f29e7dfd034e3b93f15657e608a29
2024-08-29 21:03:53 +0000 to 2024-09-15 19:13:12 +0000
- chore: revert change to Cargo.lock in f25806c (rust-lang/cargo#14547)
- Disable the shell_completions tests (rust-lang/cargo#14546)
- fix(vendor): trust crate version only when coming from registries (rust-lang/cargo#14530)
- docs: Feature resolver version 2: clarify use of 'target' (rust-lang/cargo#14540)
- Update docs for how cargo is published (rust-lang/cargo#14539)
- feat: Add native comlpetion with CompleteEnv under the nightly (rust-lang/cargo#14493)
- fix(new): Add to workspace relative to manifest, not current-dir (rust-lang/cargo#14505)
- Fix parsing of comma separated values in --crate-type flag (rust-lang/cargo#14499)
- Include public/private dependency status in `cargo metadata` (rust-lang/cargo#14504)
- Remove unnecessary symbols (rust-lang/cargo#14519)
- docs: bin source can be `src/main.rs` and/or in `src/bin/` (rust-lang/cargo#14515)
- fix(toml): Don't require MSRV bump for pub/priv (rust-lang/cargo#14507)
- bail before packaging on same version (rust-lang/cargo#14448)
- Implement path-bases (RFC 3529) 2/n: `cargo [add|remove|update]` support (rust-lang/cargo#14427)
- Publish workspace (rust-lang/cargo#14433)
- Bump ci's version of cargo-semver-version (rust-lang/cargo#14503)
- Document -Zpackage-workspace (rust-lang/cargo#14496)
- uplift windows gnullvm import libraries (rust-lang/cargo#14451)
- Bump to 0.84.0; update changelog (rust-lang/cargo#14495)
- Fix cargo add behaving different when translating package name (rust-lang/cargo#13765)
- chore(deps): update rust crate core-foundation to 0.10.0 (rust-lang/cargo#14475)
- feat(resolve): Report MSRV compatible version instead of incomptible (rust-lang/cargo#14471)
- Don't automatically include the current crate when packaging (rust-lang/cargo#14488)
- Fix elided lifetime (rust-lang/cargo#14487)
- chore(deps): update rust crate pasetors to 0.7.0 (rust-lang/cargo#14478)
@rustbot rustbot added this to the 1.83.0 milestone Sep 16, 2024
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Sep 16, 2024
Update cargo

25 commits in c1fa840a85eca53818895901a53fae34247448b2..a9a418d1a22f29e7dfd034e3b93f15657e608a29
2024-08-29 21:03:53 +0000 to 2024-09-15 19:13:12 +0000
- chore: revert change to Cargo.lock in f25806c (rust-lang/cargo#14547)
- Disable the shell_completions tests (rust-lang/cargo#14546)
- fix(vendor): trust crate version only when coming from registries (rust-lang/cargo#14530)
- docs: Feature resolver version 2: clarify use of 'target' (rust-lang/cargo#14540)
- Update docs for how cargo is published (rust-lang/cargo#14539)
- feat: Add native comlpetion with CompleteEnv under the nightly (rust-lang/cargo#14493)
- fix(new): Add to workspace relative to manifest, not current-dir (rust-lang/cargo#14505)
- Fix parsing of comma separated values in --crate-type flag (rust-lang/cargo#14499)
- Include public/private dependency status in `cargo metadata` (rust-lang/cargo#14504)
- Remove unnecessary symbols (rust-lang/cargo#14519)
- docs: bin source can be `src/main.rs` and/or in `src/bin/` (rust-lang/cargo#14515)
- fix(toml): Don't require MSRV bump for pub/priv (rust-lang/cargo#14507)
- bail before packaging on same version (rust-lang/cargo#14448)
- Implement path-bases (RFC 3529) 2/n: `cargo [add|remove|update]` support (rust-lang/cargo#14427)
- Publish workspace (rust-lang/cargo#14433)
- Bump ci's version of cargo-semver-version (rust-lang/cargo#14503)
- Document -Zpackage-workspace (rust-lang/cargo#14496)
- uplift windows gnullvm import libraries (rust-lang/cargo#14451)
- Bump to 0.84.0; update changelog (rust-lang/cargo#14495)
- Fix cargo add behaving different when translating package name (rust-lang/cargo#13765)
- chore(deps): update rust crate core-foundation to 0.10.0 (rust-lang/cargo#14475)
- feat(resolve): Report MSRV compatible version instead of incomptible (rust-lang/cargo#14471)
- Don't automatically include the current crate when packaging (rust-lang/cargo#14488)
- Fix elided lifetime (rust-lang/cargo#14487)
- chore(deps): update rust crate pasetors to 0.7.0 (rust-lang/cargo#14478)
@epage epage deleted the dynamic_switch branch September 16, 2024 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Area: Command-line interface, option parsing, etc. A-documenting-cargo-itself Area: Cargo's documentation A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants