clap
clap copied to clipboard
[clap_mangen] possible values not shown in generated man page
Please complete the following tasks
- [X] I have searched the discussions
- [X] I have searched the open and rejected issues
Rust Version
rustc 1.61.0 (fe5b13d68 2022-05-18)
Clap Version
3.2.6
Minimal reproducible code
use clap::{Parser, CommandFactory};
use clap_mangen::Man;
#[derive(Parser)]
struct Cli {
#[clap(long, action)]
pub test: Option<bool>,
}
fn main() -> std::io::Result<()> {
let mut cmd = Cli::command();
cmd.write_long_help(&mut std::io::stderr())?;
eprintln!("{}", "-".repeat(30));
let man = Man::new(cmd);
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;
println!("{}", String::from_utf8_lossy(&buffer));
Ok(())
}
Steps to reproduce the bug with the above code
- Add
clap = { version = "3.2.6", features = ["derive"] }
andclap_mangen = "0.1.9"
toCargo.toml
- Run
cargo run | man -P cat -l -
Actual Behaviour
The above example prints both the normal help message generated by clap
and the man page generated by clap_mangen
(example output is provided below). The man page does not mention the possible values (true
and false
) anywhere. The same is true for enums.
Expected Behaviour
The man page should mention the possible values just like the help message does ([possible values: true, false]
).
Additional Context
Output of above example:
asd
USAGE:
asd [OPTIONS]
OPTIONS:
-h, --help
Print help information
--test <TEST>
[possible values: true, false]
------------------------------
asd(1) General Commands Manual asd(1)
NAME
asd
SYNOPSIS
asd [-h|--help] [--test]
DESCRIPTION
OPTIONS
-h, --help
Print help information
--test=TEST
asd asd(1)
Debug Output
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
Running `/home/silas/.cache/cargo/debug/asd`
[ clap::builder::command] Command::_build: name="asd"
[ clap::builder::command] Command::_propagate:asd
[ clap::builder::command] Command::_check_help_and_version: asd
[ clap::builder::command] Command::_check_help_and_version: Removing generated version
[ clap::builder::command] Command::_propagate_global_args:asd
[ clap::builder::command] Command::_derive_display_order:asd
[clap::builder::debug_asserts] Command::_debug_asserts
[clap::builder::debug_asserts] Arg::_debug_asserts:help
[clap::builder::debug_asserts] Arg::_debug_asserts:test
[clap::builder::debug_asserts] Command::_verify_positionals
[ clap::output::help] Help::new cmd=asd, use_long=true
[ clap::output::help] Help::write_help
[ clap::output::help] should_show_arg: use_long=true, arg=help
[ clap::output::help] Help::write_templated_help
[ clap::output::help] Help::write_before_help
[ clap::output::help] Help::write_bin_name
asd
USAGE:
[ clap::output::usage] Usage::create_usage_no_title
[ clap::output::usage] Usage::create_help_usage; incl_reqs=true
[ clap::output::usage] Usage::get_required_usage_from: incls=[], matcher=false, incl_last=false
[ clap::output::usage] Usage::get_required_usage_from: unrolled_reqs={}
[ clap::output::usage] Usage::get_required_usage_from: ret_val={}
[ clap::output::usage] Usage::needs_options_tag
[ clap::output::usage] Usage::needs_options_tag:iter: f=help
[ clap::output::usage] Usage::needs_options_tag:iter Option is built-in
[ clap::output::usage] Usage::needs_options_tag:iter: f=test
[ clap::builder::command] Command::groups_for_arg: id=test
[ clap::output::usage] Usage::needs_options_tag:iter: [OPTIONS] required
[ clap::output::usage] Usage::create_help_usage: usage=asd [OPTIONS]
asd [OPTIONS]
[ clap::output::help] Help::write_all_args
[ clap::output::help] should_show_arg: use_long=true, arg=help
[ clap::output::help] should_show_arg: use_long=true, arg=test
OPTIONS:
[ clap::output::help] Help::write_args OPTIONS
[ clap::output::help] should_show_arg: use_long=true, arg=help
[ clap::output::help] Help::write_args: arg="help" longest=6
[ clap::output::help] should_show_arg: use_long=true, arg=test
[ clap::output::help] Help::write_args: arg="test" longest=13
[ clap::output::help] should_show_arg: use_long=true, arg=help
[ clap::output::help] Help::spec_vals: a=--help
[ clap::output::help] Help::spec_vals: a=--help
[ clap::output::help] Help::short
-h[ clap::output::help] Help::long
, --help[ clap::output::help] Help::val: arg=help
[ clap::output::help] Help::align_to_about: arg=help, next_line_help=true, longest=13
[ clap::output::help] Help::align_to_about: printing long help so skip alignment
[ clap::output::help] Help::help
[ clap::output::help] Help::help: Next Line...true
[ clap::output::help] Help::help: Too long...
[ clap::output::help] No
Print help information
[ clap::output::help] Help::spec_vals: a=--test <TEST>
[ clap::output::help] Help::spec_vals: Found possible vals...[PossibleValue { name: "true", help: None, aliases: [], hide: false }, PossibleValue { name: "false", help: None, aliases: [], hide: false }]
[ clap::output::help] Help::short
[ clap::output::help] Help::long
--test[ clap::output::help] Help::val: arg=test
<TEST>[ clap::output::help] Help::align_to_about: arg=test, next_line_help=true, longest=13
[ clap::output::help] Help::align_to_about: printing long help so skip alignment
[ clap::output::help] Help::help
[ clap::output::help] Help::help: Next Line...true
[ clap::output::help] Help::help: Too long...
[ clap::output::help] No
[possible values: true, false][ clap::output::help] Help::write_after_help
------------------------------
[ clap::builder::command] Command::_build: name="asd"
[ clap::builder::command] Command::_build: already built
[ clap::builder::command] Command::_build_bin_names
[ clap::output::usage] Usage::get_required_usage_from: incls=[], matcher=false, incl_last=true
[ clap::output::usage] Usage::get_required_usage_from: unrolled_reqs={}
[ clap::output::usage] Usage::get_required_usage_from: ret_val={}
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.TH asd 1 "asd "
.SH NAME
asd
.SH SYNOPSIS
\fBasd\fR [\fB\-h\fR|\fB\-\-help\fR] [\fB\-\-test\fR]
.SH DESCRIPTION
.SH OPTIONS
.TP
\fB\-h\fR, \fB\-\-help\fR
Print help information
.TP
\fB\-\-test\fR=\fITEST\fR
Huh, we have #3360 for improving possible values but not an issue for tracking showing them in the first place.
I wouldn't mind working on this if it's not being handled already
Go for it!