Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clap_mangen] possible values not shown in generated man page #3861

Closed
2 tasks done
RubixDev opened this issue Jun 22, 2022 · 3 comments · Fixed by #4082
Closed
2 tasks done

[clap_mangen] possible values not shown in generated man page #3861

RubixDev opened this issue Jun 22, 2022 · 3 comments · Fixed by #4082
Labels
A-man Area: man generator C-bug Category: Updating dependencies E-easy Call for participation: Experience needed to fix: Easy / not much

Comments

@RubixDev
Copy link
Contributor

Please complete the following tasks

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

  1. Add clap = { version = "3.2.6", features = ["derive"] } and clap_mangen = "0.1.9" to Cargo.toml
  2. 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



@RubixDev RubixDev added the C-bug Category: Updating dependencies label Jun 22, 2022
@epage
Copy link
Member

epage commented Jun 22, 2022

Huh, we have #3360 for improving possible values but not an issue for tracking showing them in the first place.

@epage epage added E-easy Call for participation: Experience needed to fix: Easy / not much A-man Area: man generator labels Jun 22, 2022
@Calder-Ty
Copy link
Contributor

I wouldn't mind working on this if it's not being handled already

@epage
Copy link
Member

epage commented Aug 8, 2022

Go for it!

Calder-Ty added a commit to Calder-Ty/clap that referenced this issue Aug 16, 2022
This adds feature parity for mangen with the standard help output. Users
will now see the list of possible values for value arguments.

One change that was made to make this possible was adding the method
`get_possible_values` to the public API for an arg. I tried to think of
a way to get around this, but because this is the interface that the
help generation uses, and it is part of the crate public interface
I thing adding it as a part of the public API might be for the best.

fixes: clap-rs#3861
Calder-Ty added a commit to Calder-Ty/clap that referenced this issue Aug 16, 2022
This adds feature parity for mangen with the standard help output. Users
will now see the list of possible values for value arguments.

One change that was made to make this possible was adding the method
`get_possible_values` to the public API for an arg. I tried to think of
a way to get around this, but because this is the interface that the
help generation uses, and it is part of the crate public interface
I thing adding it as a part of the public API might be for the best.

fixes: clap-rs#3861
Calder-Ty added a commit to Calder-Ty/clap that referenced this issue Aug 16, 2022
This adds feature parity for mangen with the standard help output. Users
will now see the list of possible values for value arguments.

One change that was made to make this possible was adding the method
`get_possible_values` to the public API for an arg. I tried to think of
a way to get around this, but because this is the interface that the
help generation uses, and it is part of the crate public interface
I thing adding it as a part of the public API might be for the best.

fixes: clap-rs#3861
Calder-Ty added a commit to Calder-Ty/clap that referenced this issue Aug 20, 2022
This adds feature parity for mangen with the standard help output. Users
will now see the list of possible values for value arguments.

One change that was made to make this possible was adding the method
`get_possible_values` to the public API for an arg. I tried to think of
a way to get around this, but because this is the interface that the
help generation uses, and it is part of the crate public interface
I thing adding it as a part of the public API might be for the best.

fixes: clap-rs#3861
Calder-Ty added a commit to Calder-Ty/clap that referenced this issue Aug 24, 2022
This adds feature parity for mangen with the standard help output. Users
will now see the list of possible values for value arguments.

One change that was made to make this possible was adding the method
`get_possible_values` to the public API for an arg. I tried to think of
a way to get around this, but because this is the interface that the
help generation uses, and it is part of the crate public interface
I thing adding it as a part of the public API might be for the best.

fixes: clap-rs#3861
@epage epage closed this as completed in 6342802 Aug 24, 2022
Calder-Ty added a commit to Calder-Ty/clap that referenced this issue Aug 30, 2022
This adds feature parity for mangen with the standard help output. Users
will now see the list of possible values for value arguments.

One change that was made to make this possible was adding the method
`get_possible_values` to the public API for an arg. I tried to think of
a way to get around this, but because this is the interface that the
help generation uses, and it is part of the crate public interface
I thing adding it as a part of the public API might be for the best.

cherry-pick to backport this fix to v3

fixes: clap-rs#3861
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-man Area: man generator C-bug Category: Updating dependencies E-easy Call for participation: Experience needed to fix: Easy / not much
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants