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 custom completer for cargo <TAB> to complete aliases defined in config.toml #15319

Conversation

nooma-42
Copy link
Contributor

What does this PR try to resolve?

Related to #14520

This PR introduces auto-completion for the cargo <TAB> option. When a user types cargo <TAB> and presses the TAB key, the system will automatically suggest aliases defined in config.toml

How should we test and review this PR?

To verify this feature, follow these steps:

  1. In the terminal, type cargo <TAB>
  2. Press the TAB key.
  3. You should see aliases suggestions
2025-03-17.4.32.11.mov

@rustbot
Copy link
Collaborator

rustbot commented Mar 17, 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. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 17, 2025
@rustbot

This comment has been minimized.

@nooma-42 nooma-42 force-pushed the custom-completer-for-cargo-<TAB>-to-complete-aliases-defined-in-config.toml branch from 6d215f4 to d2dc2f8 Compare March 18, 2025 05:34
@nooma-42
Copy link
Contributor Author

Could you shed some light why would this fail? This seems to me that the compiling output is different? since I'm not working with x86_64 linux, could it be some platform specific error?

failures:

---- basic stdout ----
running `/home/runner/work/cargo/cargo/target/debug/cargo check -Zbuild-std -Zpublic-dependency --target x86_64-unknown-linux-gnu`
running `/home/runner/work/cargo/cargo/target/debug/cargo build -Zbuild-std -Zpublic-dependency --target x86_64-unknown-linux-gnu`
running `/home/runner/work/cargo/cargo/target/debug/cargo run -Zbuild-std -Zpublic-dependency --target x86_64-unknown-linux-gnu`
running `/home/runner/work/cargo/cargo/target/debug/cargo test -Zbuild-std -Zpublic-dependency --target x86_64-unknown-linux-gnu`

thread 'basic' panicked at tests/build-std/main.rs:173:10:

---- expected: tests/build-std/main.rs:161:27
++++ actual:   stderr
   1      - [COMPILING] rustc-std-workspace-std [..]
        1 + [COMPILING] unicode-width v0.1.14
   2    2 | ...
   3    3 | [COMPILING] test v0.0.0 ([..])
   4    4 | [COMPILING] foo v0.0.1 ([ROOT]/foo)
   5    5 | [FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
   6    6 | [RUNNING] unittests src/lib.rs (target/[HOST_TARGET]/debug/deps/foo-[HASH])
   7    7 | [RUNNING] unittests src/main.rs (target/[HOST_TARGET]/debug/deps/foo-[HASH])
   8    8 | [RUNNING] tests/smoke.rs (target/[HOST_TARGET]/debug/deps/smoke-[HASH])
error: test failed, to rerun pass `-p cargo --test build-std`
   9    9 | [DOCTEST] foo

Update with SNAPSHOTS=overwrite

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    basic

test result: FAILED. 6 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [56](https://github.com/rust-lang/cargo/actions/runs/13917114566/job/38942064437?pr=15319#step:6:57).88s

@weihanglo
Copy link
Member

@nooma-42 I'll look into build-std failure today.

@weihanglo
Copy link
Member

A rebase onto master should fix the CI failure.

@nooma-42 nooma-42 force-pushed the custom-completer-for-cargo-<TAB>-to-complete-aliases-defined-in-config.toml branch from f5da632 to 195a6f9 Compare March 19, 2025 03:40
@rustbot rustbot added A-configuration Area: cargo config files and env vars A-documenting-cargo-itself Area: Cargo's documentation A-workspaces Area: workspaces labels Mar 19, 2025
@nooma-42 nooma-42 force-pushed the custom-completer-for-cargo-<TAB>-to-complete-aliases-defined-in-config.toml branch 2 times, most recently from 74aba4d to c9adff5 Compare March 19, 2025 07:32
@nooma-42 nooma-42 force-pushed the custom-completer-for-cargo-<TAB>-to-complete-aliases-defined-in-config.toml branch from c9adff5 to 7e98310 Compare March 20, 2025 07:04
Copy link
Contributor

@epage epage left a comment

Choose a reason for hiding this comment

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

Thanks!

@epage epage added this pull request to the merge queue Mar 20, 2025
Merged via the queue into rust-lang:master with commit 307cbfd Mar 20, 2025
21 checks passed
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-configuration Area: cargo config files and env vars A-documenting-cargo-itself Area: Cargo's documentation A-workspaces Area: workspaces S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants