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

Show default subcommand for --help when using #[default] #5762

Open
2 tasks done
gd0st opened this issue Oct 2, 2024 · 1 comment
Open
2 tasks done

Show default subcommand for --help when using #[default] #5762

gd0st opened this issue Oct 2, 2024 · 1 comment
Labels
A-derive Area: #[derive]` macro API C-enhancement Category: Raise on the bar on expectations

Comments

@gd0st
Copy link

gd0st commented Oct 2, 2024

Please complete the following tasks

Clap Version

4.4.8

Describe your use case

It would be nice to for the long --help string to show if a sub-command has been marked as the default when the sub-command is non optional.

Describe the solution you'd like

The current behavior is to just list all of the sub-commands as such

#[derive(clap::Subcommand, Debug, Clone, Default)]
pub enum Subcommand {
    Show,
    Import,
    Config,
    #[default]
    Browse,
    Run {
        path: PathBuf,
    },
}
Usage: kadeu [OPTIONS] <CONFIG> <COMMAND>

Commands:
  show     
  import   
  config   
  browse
  run      
  help     Print this message or the help of the given subcommand(s)

What would be nice is for the help message to feature this instead

Usage: kadeu [OPTIONS] <CONFIG> <COMMAND>

Commands:
  show     
  import   
  config   
  browse (default)
  run      
  help     Print this message or the help of the given subcommand(s)

I don't know how feasible this can be, but I believe this could be a nice addition

Alternatives, if applicable

No response

Additional Context

No response

@gd0st gd0st added the C-enhancement Category: Raise on the bar on expectations label Oct 2, 2024
@epage
Copy link
Member

epage commented Oct 2, 2024

The strange there here is clap has no concept of a #[default] subcommand.

The closest to that is the git stash pattern which we demonstrate in our git cookbook entry where the default is flattened into the parent command

@epage epage added the A-derive Area: #[derive]` macro API label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-derive Area: #[derive]` macro API C-enhancement Category: Raise on the bar on expectations
Projects
None yet
Development

No branches or pull requests

2 participants