`clap_usage` generate invalid KDL document with `Option<bool>`
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 59
- Avg merge
- 5h 58m
- Merged PRs (30d)
- 362
Description
I use `clap` to build my cli app, and `clap_usage` to generate a KDL document for completions. Below is a minimum reproduction:
```rust
#[derive(clap::Parser)]
struct Args {
#[clap(short = 'b')]
this_is_a_bool: Option,
}
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 {
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 {
6 │ choices true false
· ──┬─
· ╰── not identifier string
7 │ }
╰────
Error:
× Expected identifier string
╭─[6:22]
5 │ arg {
6 │ choices true false
· ──┬──
· ╰── not identifier string
7 │ }
╰────
```
`clap` and `clap_usage` is the latest version:
```toml
[dependencies]
clap = "4.5.46"
clap_usage = "2.0.3"
```
It only happens to `Option`. If replace it with `bool` or `Option`, everything seems ok.
Contributor guide
Assessment
This issue has not been assessed yet.