clap icon indicating copy to clipboard operation
clap copied to clipboard

Clap completion can't tell positional args apart

Open Morganamilo opened this issue 1 year ago • 0 comments

Please complete the following tasks

Rust Version

rustc 1.71.0-nightly (f5559e338 2023-04-24)

Clap Version

4.4.10

Minimal reproducible code

use clap::Parser;
use clap::ValueHint;

#[derive(Parser, Debug)]
#[command(args_override_self = true)]
pub struct Args {
    #[arg(required = true)]
    pub targets: Vec<String>,
    #[arg(
        value_hint = ValueHint::AnyPath,
    )]
    #[arg(required = true, last = true)]
    pub files: Vec<String>,
}

Steps to reproduce the bug with the above code

command <tab> should and does complete files but command foo -- <tab> should not complete files.

If you swap the hints then command <tab> does not complete files and neither does command foo -- <tab> .

Actual Behaviour

Clap uses the hint for the first arg to complete both args.

Expected Behaviour

Clap should complete each arg according to hint.

Additional Context

No response

Debug Output

No response

Morganamilo avatar Dec 04 '23 04:12 Morganamilo