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

Options are silently ignored when using aliased commands #7834

Closed
tmiasko opened this issue Jan 26, 2020 · 0 comments · Fixed by #7837
Closed

Options are silently ignored when using aliased commands #7834

tmiasko opened this issue Jan 26, 2020 · 0 comments · Fixed by #7837
Labels
A-cli Area: Command-line interface, option parsing, etc. C-bug Category: bug

Comments

@tmiasko
Copy link
Contributor

tmiasko commented Jan 26, 2020

For example, when using b as an alias of build, the -Ztimings flag is ignored:

$ cargo -Ztimings b
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
$ cargo -Ztimings build
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
      Timing report saved to /home/...

The original context: rust-lang/rust#68548 (comment)

Notes

cargo 1.42.0-nightly (f6449ba 2020-01-21)

@tmiasko tmiasko added the C-bug Category: bug label Jan 26, 2020
@ehuss ehuss added the A-cli Area: Command-line interface, option parsing, etc. label Jan 26, 2020
bors added a commit that referenced this issue Jan 28, 2020
Fix using global options before an alias.

Options before an alias were being ignored (like `cargo -v b`).  The solution is to extract those global options before expanding an alias, and then merging it later.

An alternative to this is to try to avoid discarding the options during expansion, but I couldn't figure out a way to get the position of the subcommand in the argument list.  Clap only provides a way to get the arguments *following* the subcommand.

I also cleaned up some of the code in `Config::configure`, which was carrying some weird baggage from previous refactorings.

Fixes #7834
@bors bors closed this as completed in 972b9f5 Jan 31, 2020
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. C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants