]>
git.proxmox.com Git - rustc.git/blob - vendor/structopt/examples/rename_all.rs
1 //! Example on how the `rename_all` parameter works.
3 //! `rename_all` can be used to override the casing style used during argument
4 //! generation. By default the `kebab-case` style will be used but there are a wide
5 //! variety of other styles available.
7 //! ## Supported styles overview:
9 //! - **Camel Case**: Indicate word boundaries with uppercase letter, excluding
11 //! - **Kebab Case**: Keep all letters lowercase and indicate word boundaries
13 //! - **Pascal Case**: Indicate word boundaries with uppercase letter,
14 //! including the first word.
15 //! - **Screaming Snake Case**: Keep all letters uppercase and indicate word
16 //! boundaries with underscores.
17 //! - **Snake Case**: Keep all letters lowercase and indicate word boundaries
19 //! - **Verbatim**: Use the original attribute name defined in the code.
21 //! - **Lower Case**: Keep all letters lowercase and remove word boundaries.
23 //! - **Upper Case**: Keep all letters upperrcase and remove word boundaries.
25 use structopt
::StructOpt
;
27 #[derive(StructOpt, Debug)]
28 #[structopt(name = "rename_all", rename_all = "screaming_snake_case")]
30 // This subcommand will be named `FIRST_COMMAND`. As the command doesn't
31 // override the initial casing style, ...
32 /// A screaming loud first command. Only use if necessary.
34 // this flag will be available as `--FOO` and `-F`.
35 /// This flag will even scream louder.
36 #[structopt(long, short)]
40 // As we override the casing style for this variant the related subcommand
41 // will be named `SecondCommand`.
42 /// Not nearly as loud as the first command.
43 #[structopt(rename_all = "pascal_case")]
45 // We can also override it again on a single field.
46 /// Nice quiet flag. No one is annoyed.
47 #[structopt(rename_all = "snake_case", long)]
50 // Renaming will not be propagated into subcommand flagged enums. If
51 // a non default casing style is required it must be defined on the
53 #[structopt(subcommand)]
56 // or flattened structs.
58 options
: BonusOptions
,
62 #[derive(StructOpt, Debug)]
64 // This one will be available as `first-subcommand`.
68 #[derive(StructOpt, Debug)]
70 // And this one will be available as `baz-option`.
76 let opt
= Opt
::from_args();
77 println
!("{:?}", opt
);