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

flatten_help shows a hide(true) annotated subcommand in the overview #5225

Closed
2 tasks done
Apanatshka opened this issue Nov 27, 2023 · 0 comments · Fixed by #5228
Closed
2 tasks done

flatten_help shows a hide(true) annotated subcommand in the overview #5225

Apanatshka opened this issue Nov 27, 2023 · 0 comments · Fixed by #5228
Labels
C-bug Category: Updating dependencies

Comments

@Apanatshka
Copy link

Apanatshka commented Nov 27, 2023

Please complete the following tasks

Rust Version

rustc 1.72.1 (d5c2e9c34 2023-09-13)

Clap Version

4.4.8

Minimal reproducible code

use clap::{Parser, Subcommand};

#[derive(Subcommand, Debug)]
enum Command {
    Public,
    #[clap(hide(true))]
    Hidden,
}

#[derive(Parser, Debug)]
#[command(flatten_help = true)]
struct Opts {
    #[command(subcommand)]
    command: Command,
}

fn main() {
    let args = Opts::parse();
    println!("{:#?}", args);
}

Steps to reproduce the bug with the above code

cargo run

Actual Behaviour

Prints:

Usage: clap-flatten-help public
       clap-flatten-help hidden
       clap-flatten-help help [COMMAND]...

Options:
  -h, --help  Print help

clap-flatten-help public:
  -h, --help  Print help

clap-flatten-help help:
  [COMMAND]...  Print help for the subcommand(s)

Expected Behaviour

Leaves out the hidden subcommand in the overview:

Usage: clap-flatten-help public
       clap-flatten-help help [COMMAND]...

Options:
  -h, --help  Print help

clap-flatten-help public:
  -h, --help  Print help

clap-flatten-help help:
  [COMMAND]...  Print help for the subcommand(s)

Additional Context

No response

Debug Output

Click to expand
[clap_builder::builder::command]Command::_do_parse
[clap_builder::builder::command]Command::_build: name="clap-flatten-help"
[clap_builder::builder::command]Command::_propagate:clap-flatten-help
[clap_builder::builder::command]Command::_check_help_and_version:clap-flatten-help expand_help_tree=false
[clap_builder::builder::command]Command::long_help_exists
[clap_builder::builder::command]Command::_check_help_and_version: Building default --help
[clap_builder::builder::command]Command::_check_help_and_version: Building help subcommand
[clap_builder::builder::command]Command::_propagate_global_args:clap-flatten-help
[clap_builder::builder::debug_asserts]Command::_debug_asserts
[clap_builder::builder::debug_asserts]Arg::_debug_asserts:help
[clap_builder::builder::debug_asserts]Command::_verify_positionals
[clap_builder::parser::parser]Parser::get_matches_with
[clap_builder::parser::parser]Parser::add_defaults
[clap_builder::parser::parser]Parser::add_defaults:iter:help:
[clap_builder::parser::parser]Parser::add_default_value: doesn't have conditional defaults
[clap_builder::parser::parser]Parser::add_default_value:iter:help: doesn't have default vals
[clap_builder::parser::validator]Validator::validate
[clap_builder::builder::command]Command::write_help_err: clap-flatten-help, use_long=false
[  clap_builder::output::help]write_help
[clap_builder::output::help_template]HelpTemplate::new cmd=clap-flatten-help, use_long=false
[clap_builder::output::help_template]should_show_arg: use_long=false, arg=help
[clap_builder::output::help_template]HelpTemplate::write_templated_help
[clap_builder::output::help_template]HelpTemplate::write_before_help
[ clap_builder::output::usage]Usage::create_usage_no_title
[ clap_builder::output::usage]Usage::create_usage_no_title
[ clap_builder::output::usage]Usage::write_help_usage
[clap_builder::builder::command]Command::_build: name="clap-flatten-help"
[clap_builder::builder::command]Command::_build: already built
[clap_builder::builder::command]Command::_build: name="public"
[clap_builder::builder::command]Command::_propagate:public
[clap_builder::builder::command]Command::_check_help_and_version:public expand_help_tree=true
[clap_builder::builder::command]Command::long_help_exists
[clap_builder::builder::command]Command::_check_help_and_version: Building default --help
[clap_builder::builder::command]Command::_propagate_global_args:public
[clap_builder::builder::debug_asserts]Command::_debug_asserts
[clap_builder::builder::debug_asserts]Arg::_debug_asserts:help
[clap_builder::builder::debug_asserts]Command::_verify_positionals
[clap_builder::builder::command]Command::_build: name="hidden"
[clap_builder::builder::command]Command::_propagate:hidden
[clap_builder::builder::command]Command::_check_help_and_version:hidden expand_help_tree=true
[clap_builder::builder::command]Command::long_help_exists
[clap_builder::builder::command]Command::_check_help_and_version: Building default --help
[clap_builder::builder::command]Command::_propagate_global_args:hidden
[clap_builder::builder::debug_asserts]Command::_debug_asserts
[clap_builder::builder::debug_asserts]Arg::_debug_asserts:help
[clap_builder::builder::debug_asserts]Command::_verify_positionals
[clap_builder::builder::command]Command::_build: name="help"
[clap_builder::builder::command]Command::_propagate:help
[clap_builder::builder::command]Command::_check_help_and_version:help expand_help_tree=true
[clap_builder::builder::command]Command::long_help_exists
[clap_builder::builder::command]Command::_propagate_global_args:help
[clap_builder::builder::debug_asserts]Command::_debug_asserts
[clap_builder::builder::debug_asserts]Arg::_debug_asserts:subcommand
[clap_builder::builder::debug_asserts]Command::_verify_positionals
[clap_builder::builder::command]Command::_build_bin_names
[ clap_builder::output::usage]Usage::get_required_usage_from: incls=[], matcher=false, incl_last=true
[ clap_builder::output::usage]Usage::get_required_usage_from: unrolled_reqs=[]
[ clap_builder::output::usage]Usage::get_required_usage_from: ret_val=[]
[clap_builder::builder::command]Command::_build_bin_names:iter: bin_name set...
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting usage_name of public to "clap-flatten-help public"
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting bin_name of public to "clap-flatten-help public"
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting display_name of public to "clap-flatten-help-public"
[clap_builder::builder::command]Command::_build_bin_names
[ clap_builder::output::usage]Usage::get_required_usage_from: incls=[], matcher=false, incl_last=true
[ clap_builder::output::usage]Usage::get_required_usage_from: unrolled_reqs=[]
[ clap_builder::output::usage]Usage::get_required_usage_from: ret_val=[]
[clap_builder::builder::command]Command::_build_bin_names:iter: bin_name set...
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting usage_name of hidden to "clap-flatten-help hidden"
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting bin_name of hidden to "clap-flatten-help hidden"
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting display_name of hidden to "clap-flatten-help-hidden"
[clap_builder::builder::command]Command::_build_bin_names
[ clap_builder::output::usage]Usage::get_required_usage_from: incls=[], matcher=false, incl_last=true
[ clap_builder::output::usage]Usage::get_required_usage_from: unrolled_reqs=[]
[ clap_builder::output::usage]Usage::get_required_usage_from: ret_val=[]
[clap_builder::builder::command]Command::_build_bin_names:iter: bin_name set...
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting usage_name of help to "clap-flatten-help help"
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting bin_name of help to "clap-flatten-help help"
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting display_name of help to "clap-flatten-help-help"
[clap_builder::builder::command]Command::_build_bin_names
[ clap_builder::output::usage]Usage::get_required_usage_from: incls=[], matcher=false, incl_last=true
[ clap_builder::output::usage]Usage::get_required_usage_from: unrolled_reqs=[]
[ clap_builder::output::usage]Usage::get_required_usage_from: ret_val=[]
[ clap_builder::output::usage]Usage::create_usage_no_title
[ clap_builder::output::usage]Usage::write_help_usage
[ clap_builder::output::usage]Usage::write_arg_usage; incl_reqs=true
[ clap_builder::output::usage]Usage::needs_options_tag
[ clap_builder::output::usage]Usage::needs_options_tag:iter: f=help
[ clap_builder::output::usage]Usage::needs_options_tag:iter Option is built-in
[ clap_builder::output::usage]Usage::needs_options_tag: [OPTIONS] not required
[ clap_builder::output::usage]Usage::write_args: incls=[]
[ clap_builder::output::usage]Usage::get_args: unrolled_reqs=[]
[ clap_builder::output::usage]Usage::write_subcommand_usage
[ clap_builder::output::usage]Usage::create_usage_no_title
[ clap_builder::output::usage]Usage::write_help_usage
[ clap_builder::output::usage]Usage::write_arg_usage; incl_reqs=true
[ clap_builder::output::usage]Usage::needs_options_tag
[ clap_builder::output::usage]Usage::needs_options_tag:iter: f=help
[ clap_builder::output::usage]Usage::needs_options_tag:iter Option is built-in
[ clap_builder::output::usage]Usage::needs_options_tag: [OPTIONS] not required
[ clap_builder::output::usage]Usage::write_args: incls=[]
[ clap_builder::output::usage]Usage::get_args: unrolled_reqs=[]
[ clap_builder::output::usage]Usage::write_subcommand_usage
[ clap_builder::output::usage]Usage::create_usage_no_title
[ clap_builder::output::usage]Usage::write_help_usage
[ clap_builder::output::usage]Usage::write_arg_usage; incl_reqs=true
[ clap_builder::output::usage]Usage::needs_options_tag
[ clap_builder::output::usage]Usage::needs_options_tag: [OPTIONS] not required
[ clap_builder::output::usage]Usage::write_args: incls=[]
[ clap_builder::output::usage]Usage::get_args: unrolled_reqs=[]
[ clap_builder::output::usage]Usage::write_subcommand_usage
[ clap_builder::output::usage]Usage::create_usage_no_title: usage=clap-flatten-help public
       clap-flatten-help hidden
       clap-flatten-help help [COMMAND]...
[clap_builder::output::help_template]HelpTemplate::write_all_args
[clap_builder::output::help_template]should_show_arg: use_long=false, arg=help
[clap_builder::output::help_template]HelpTemplate::write_args Options
[clap_builder::output::help_template]should_show_arg: use_long=false, arg=help
[clap_builder::output::help_template]HelpTemplate::write_args: arg="help" longest=6
[clap_builder::output::help_template]should_show_arg: use_long=false, arg=help
[clap_builder::output::help_template]HelpTemplate::spec_vals: a=--help
[clap_builder::output::help_template]HelpTemplate::spec_vals: a=--help
[clap_builder::output::help_template]HelpTemplate::short
[clap_builder::output::help_template]HelpTemplate::long
[clap_builder::output::help_template]HelpTemplate::align_to_about: arg=help, next_line_help=false, longest=6
[clap_builder::output::help_template]HelpTemplate::align_to_about: positional=false arg_len=6, spaces=2
[clap_builder::output::help_template]HelpTemplate::help
[clap_builder::output::help_template]HelpTemplate::help: help_width=14, spaces=10, avail=86
[clap_builder::builder::command]Command::_build: name="clap-flatten-help"
[clap_builder::builder::command]Command::_build: already built
[clap_builder::builder::command]Command::_build: name="public"
[clap_builder::builder::command]Command::_propagate:public
[clap_builder::builder::command]Command::_check_help_and_version:public expand_help_tree=true
[clap_builder::builder::command]Command::long_help_exists
[clap_builder::builder::command]Command::_check_help_and_version: Building default --help
[clap_builder::builder::command]Command::_propagate_global_args:public
[clap_builder::builder::debug_asserts]Command::_debug_asserts
[clap_builder::builder::debug_asserts]Arg::_debug_asserts:help
[clap_builder::builder::debug_asserts]Command::_verify_positionals
[clap_builder::builder::command]Command::_build: name="hidden"
[clap_builder::builder::command]Command::_propagate:hidden
[clap_builder::builder::command]Command::_check_help_and_version:hidden expand_help_tree=true
[clap_builder::builder::command]Command::long_help_exists
[clap_builder::builder::command]Command::_check_help_and_version: Building default --help
[clap_builder::builder::command]Command::_propagate_global_args:hidden
[clap_builder::builder::debug_asserts]Command::_debug_asserts
[clap_builder::builder::debug_asserts]Arg::_debug_asserts:help
[clap_builder::builder::debug_asserts]Command::_verify_positionals
[clap_builder::builder::command]Command::_build: name="help"
[clap_builder::builder::command]Command::_propagate:help
[clap_builder::builder::command]Command::_check_help_and_version:help expand_help_tree=true
[clap_builder::builder::command]Command::long_help_exists
[clap_builder::builder::command]Command::_propagate_global_args:help
[clap_builder::builder::debug_asserts]Command::_debug_asserts
[clap_builder::builder::debug_asserts]Arg::_debug_asserts:subcommand
[clap_builder::builder::debug_asserts]Command::_verify_positionals
[clap_builder::builder::command]Command::_build_bin_names
[ clap_builder::output::usage]Usage::get_required_usage_from: incls=[], matcher=false, incl_last=true
[ clap_builder::output::usage]Usage::get_required_usage_from: unrolled_reqs=[]
[ clap_builder::output::usage]Usage::get_required_usage_from: ret_val=[]
[clap_builder::builder::command]Command::_build_bin_names:iter: bin_name set...
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting usage_name of public to "clap-flatten-help public"
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting bin_name of public to "clap-flatten-help public"
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting display_name of public to "clap-flatten-help-public"
[clap_builder::builder::command]Command::_build_bin_names
[ clap_builder::output::usage]Usage::get_required_usage_from: incls=[], matcher=false, incl_last=true
[ clap_builder::output::usage]Usage::get_required_usage_from: unrolled_reqs=[]
[ clap_builder::output::usage]Usage::get_required_usage_from: ret_val=[]
[clap_builder::builder::command]Command::_build_bin_names:iter: bin_name set...
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting usage_name of hidden to "clap-flatten-help hidden"
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting bin_name of hidden to "clap-flatten-help hidden"
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting display_name of hidden to "clap-flatten-help-hidden"
[clap_builder::builder::command]Command::_build_bin_names
[ clap_builder::output::usage]Usage::get_required_usage_from: incls=[], matcher=false, incl_last=true
[ clap_builder::output::usage]Usage::get_required_usage_from: unrolled_reqs=[]
[ clap_builder::output::usage]Usage::get_required_usage_from: ret_val=[]
[clap_builder::builder::command]Command::_build_bin_names:iter: bin_name set...
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting usage_name of help to "clap-flatten-help help"
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting bin_name of help to "clap-flatten-help help"
[clap_builder::builder::command]Command::_build_bin_names:iter: Setting display_name of help to "clap-flatten-help-help"
[clap_builder::builder::command]Command::_build_bin_names
[ clap_builder::output::usage]Usage::get_required_usage_from: incls=[], matcher=false, incl_last=true
[ clap_builder::output::usage]Usage::get_required_usage_from: unrolled_reqs=[]
[ clap_builder::output::usage]Usage::get_required_usage_from: ret_val=[]
[clap_builder::output::help_template]HelpTemplate::write_flat_subcommands, cmd=clap-flatten-help, first=false
[clap_builder::output::help_template]should_show_arg: use_long=false, arg=help
[clap_builder::output::help_template]HelpTemplate::write_args clap-flatten-help public
[clap_builder::output::help_template]should_show_arg: use_long=false, arg=help
[clap_builder::output::help_template]HelpTemplate::write_args: arg="help" longest=6
[clap_builder::output::help_template]should_show_arg: use_long=false, arg=help
[clap_builder::output::help_template]HelpTemplate::spec_vals: a=--help
[clap_builder::output::help_template]HelpTemplate::spec_vals: a=--help
[clap_builder::output::help_template]HelpTemplate::short
[clap_builder::output::help_template]HelpTemplate::long
[clap_builder::output::help_template]HelpTemplate::align_to_about: arg=help, next_line_help=false, longest=6
[clap_builder::output::help_template]HelpTemplate::align_to_about: positional=false arg_len=6, spaces=2
[clap_builder::output::help_template]HelpTemplate::help
[clap_builder::output::help_template]HelpTemplate::help: help_width=14, spaces=10, avail=86
[clap_builder::output::help_template]should_show_arg: use_long=false, arg=subcommand
[clap_builder::output::help_template]HelpTemplate::write_args clap-flatten-help help
[clap_builder::output::help_template]should_show_arg: use_long=false, arg=subcommand
[clap_builder::output::help_template]HelpTemplate::write_args: arg="subcommand" longest=12
[clap_builder::output::help_template]should_show_arg: use_long=false, arg=subcommand
[clap_builder::output::help_template]HelpTemplate::spec_vals: a=[COMMAND]...
[clap_builder::output::help_template]HelpTemplate::spec_vals: a=[COMMAND]...
[clap_builder::output::help_template]HelpTemplate::short
[clap_builder::output::help_template]HelpTemplate::long
[clap_builder::output::help_template]HelpTemplate::align_to_about: arg=subcommand, next_line_help=false, longest=12
[clap_builder::output::help_template]HelpTemplate::align_to_about: positional=true arg_len=12, spaces=2
[clap_builder::output::help_template]HelpTemplate::help
[clap_builder::output::help_template]HelpTemplate::help: help_width=16, spaces=32, avail=84
[clap_builder::output::help_template]HelpTemplate::write_after_help
[clap_builder::builder::command]Command::color: Color setting...
[clap_builder::builder::command]Auto
[clap_builder::builder::command]Command::color: Color setting...
[clap_builder::builder::command]Auto
Usage: clap-flatten-help public
       clap-flatten-help hidden
       clap-flatten-help help [COMMAND]...

Options:
  -h, --help  Print help

clap-flatten-help public:
  -h, --help  Print help

clap-flatten-help help:
  [COMMAND]...  Print help for the subcommand(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Updating dependencies
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant