-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
I use clap to build my cli app, and clap_usage to generate a KDL document for completions. Below is a minimum reproduction:
#[derive(clap::Parser)]
struct Args {
#[clap(short = 'b')]
this_is_a_bool: Option<bool>,
}
fn main() {
use clap::CommandFactory as _;
clap_usage::generate(&mut Args::command(), "demo", &mut std::io::stdout());
}which produces:
name demo
bin demo
usage "Usage: demo [OPTIONS]"
flag -b {
arg <THIS_IS_A_BOOL> {
choices true false
}
}
When invoking usage complete-word --shell fish -s "$(cargo run)", usage complains:
× Failed to parse KDL document
Error:
× Expected identifier string
╭─[6:17]
5 │ arg <THIS_IS_A_BOOL> {
6 │ choices true false
· ──┬─
· ╰── not identifier string
7 │ }
╰────
Error:
× Expected identifier string
╭─[6:22]
5 │ arg <THIS_IS_A_BOOL> {
6 │ choices true false
· ──┬──
· ╰── not identifier string
7 │ }
╰────
clap and clap_usage is the latest version:
[dependencies]
clap = "4.5.46"
clap_usage = "2.0.3"It only happens to Option<bool>. If replace it with bool or Option<SomeValueEnums>, everything seems ok.
Metadata
Metadata
Assignees
Labels
No labels