-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
💸 $5A-completionArea: completion generatorArea: completion generatorC-bugCategory: bugCategory: bugE-mediumCall for participation: Experience needed to fix: Medium / intermediateCall for participation: Experience needed to fix: Medium / intermediate
Description
Make sure you completed the following tasks
- Searched the discussions
- Searched the closes issues
Code
use std::io::stdout;
use clap::{App, Arg, SubCommand, Shell};
fn app() -> App<'static, 'static> {
App::new("completion-bug")
.arg(
Arg::with_name("foo")
.short("f")
.long("foo")
.takes_value(true)
)
.subcommand(SubCommand::with_name("zsh"))
.subcommand(SubCommand::with_name("bash"))
}
fn main() {
let args = app().get_matches();
eprintln!("{:?}", args);
let shell = match args.subcommand() {
("zsh", _) => Shell::Zsh,
("bash", _) => Shell::Bash,
_ => unreachable!(),
};
app().gen_completions_to("completion-bug", shell, &mut stdout());
}
Steps to reproduce the issue
cargo run -- zsh > ~/.zsh_completions/_completion-bug # you might need to tweak this for your setup
zsh
# this works
completion-bug z<tab>
# this doesn't
completion-bug -f x z<tab>
# this does something unexpected
completion-bug -f z<tab>
Version
- Rust: 1.42.0
- Clap: 2.33.0
Actual Behavior Summary
completion-bug -f x z<tab>
doesn't complete anything.
This affects https://github.com/kpcyrd/sn0int because it has a lot of nested subcommands but it's very common to start the command with sn0int -w foo
which breaks the completions for everything afterwards.
The bash completions work correctly.
Expected Behavior Summary
completion-bug -f x z<tab>
should complete to completion-bug -f x zsh
Additional context
This bug was originally reported as TeXitoi/structopt#369 and then ported over to pure clap. The completions generated by the structopt program and the clap program are identical.
Metadata
Metadata
Assignees
Labels
💸 $5A-completionArea: completion generatorArea: completion generatorC-bugCategory: bugCategory: bugE-mediumCall for participation: Experience needed to fix: Medium / intermediateCall for participation: Experience needed to fix: Medium / intermediate