Skip to content

Commit

Permalink
docs: Add subcommand comment
Browse files Browse the repository at this point in the history
Discussed in comment #4692 (comment)
on_r1095242457 this adds a comment explaining where the subcommand name 
"example-derive" comes from. 

I also modified the `ExampleDerive` struct to be `ExampleDeriveArgs`. Th
is means the variant and its struct no longer have the same name and tha
t it's clearer that the struct contains the args.
  • Loading branch information
schneems committed Feb 3, 2023
1 parent 956dc6a commit 2e46d0c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions examples/cargo-example-derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ use clap::Parser;
#[command(name = "cargo")]
#[command(bin_name = "cargo")]
enum Cargo {
ExampleDerive(ExampleDerive),
// Subcommand name “example-derive” generated from variant name
ExampleDerive(ExampleDeriveArgs),
}

#[derive(clap::Args)]
#[command(author, version, about, long_about = None)]
struct ExampleDerive {
struct ExampleDeriveArgs {
#[arg(long)]
manifest_path: Option<std::path::PathBuf>,
}
Expand Down

0 comments on commit 2e46d0c

Please sign in to comment.