Skip to content

Invalid completion generation for nushell when option is of style --option.suboption <value> #6112

@0xferrous

Description

@0xferrous

Please complete the following tasks

Rust Version

rustc 1.91.0-nightly (9eb4a2652 2025-08-18)

Clap Version

clap_complete_nushell = "4.5.8", clap = "4.5.46", clap_complete = "4.5.57"

Minimal reproducible code

use clap::CommandFactory;
use clap_complete::aot::generate;

#[derive(clap::Parser)]
struct Args {
    #[arg(long = "nested.option")]
    pub nested_option: Option<u64>,
}

fn main() {
    generate(
        clap_complete_nushell::Nushell,
        &mut Args::command(),
        "repro",
        &mut std::io::stdout(),
    );
}

Steps to reproduce the bug with the above code

cargo r

Actual Behaviour

module completions {

  export extern repro [
    --nested.option: string
    --help(-h)                # Print help
  ]

}

export use completions *

generated completion is not valid nushell:

Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[entry #1:2:5]
 1 │   export extern repro [
 2 │     --nested.option: string
   ·     ───────┬───────
   ·            ╰── expected valid variable name for this long flag
 3 │     --help(-h)                # Print help
   ╰────

Expected Behaviour

Not sure what the valid generation for this option's completion will be(i will try to look into this soon), but whatever is generated should be valid nushell.

Additional Context

No response

Debug Output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-completionArea: completion generatorC-bugCategory: bugE-mediumCall for participation: Experience needed to fix: Medium / intermediate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions