#6529·clap

Completion fails past the first argument when the binary name contains a hyphen

Author: joefernerCreated Sep 20, 2026Updated Sep 20, 2026
LabelsC-bugS-triage

Please complete the following tasks

Rust Version

rustc 1.96.0 (ac68faa20 2026-05-25)

Clap Version

4.6.6

Minimal reproducible code

rust
use clap::{Arg, Command};
use clap_complete::{generate, Shell};

fn main() {
    let mut cmd = Command::new("my-tool")
        .subcommand(Command::new("build").arg(Arg::new("target").long("target")));
    generate(Shell::Bash, &mut cmd, "my-tool", &mut std::io::stdout());
}

Steps to reproduce the bug with the above code

  1. Put that snippet in a new crate with clap and clap_complete.
  2. cargo run > my-tool.bash
  3. source my-tool.bash
  4. Type my-tool build -- and press Tab twice.
  5. Nothing appears. Expected --target --help.
  6. Change both my-tool strings to mytool, repeat — now the options appear.

Actual Behaviour

Nothing appears when pressing Tab twice.

Expected Behaviour

Expected to see --target --help

Additional Context

No response

Debug Output

No response