Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide subcommand group

Tags:

rust

clap

I have code like this:

#[derive(Subcommand)]
pub enum MyTool {
    Clean(CleanPackage),
    Compile(CompilePackage),
    #[clap(subcommand)]
    Coverage(coverage::CoveragePackage),
    #[clap(subcommand)]
    Show(show::ShowTool),
    Test(TestPackage),
    View(ViewFunction),
}

I want the subcommand group under show to be hidden from help text. I have tried the following:

#[clap(subcommand, hidden)]
#[clap(subcommand, hide)]

But neither of these work. Is what I want to do possible with clap, specifically with the "structopt style" of representing the argument parser?

I'm using clap version 3.2.23.

like image 364
Daniel Porteous Avatar asked Aug 12 '26 20:08

Daniel Porteous


1 Answers

Figured it out, turns out you need to do this:

#[clap(subcommand, hide(true))]

This also works:

#[clap(subcommand, hide = true)]
like image 110
Daniel Porteous Avatar answered Aug 15 '26 10:08

Daniel Porteous



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!