|
85 | 85 | //! - `author`: Defaults to the crate author name given by Cargo. |
86 | 86 | //! - `about`: Defaults to the crate description given by Cargo. |
87 | 87 | //! |
88 | | -//! Methods from `clap::App` that don't take an `&str` can be called by |
89 | | -//! wrapping them in `raw()`, e.g. to activate colored help text: |
| 88 | +//! This approach also works for booleans and numbers which can be |
| 89 | +//! used as values of the attributes for corresponding `clap::App` |
| 90 | +//! methods (e.g. for `fn function(self, bool)` and so on). |
| 91 | +//! |
| 92 | +//! Methods from `clap::App` that don't take an atomic literal |
| 93 | +//! argument (`&str`, `bool` or numbers) can be called by wrapping |
| 94 | +//! them in `raw()`, e.g. to activate colored help text: |
90 | 95 | //! |
91 | 96 | //! ``` |
92 | 97 | //! #[macro_use] |
|
105 | 110 | //! # fn main() {} |
106 | 111 | //! ``` |
107 | 112 | //! |
108 | | -//! Then, each field of the struct not marked as a subcommand corresponds |
109 | | -//! to a `clap::Arg`. As with the struct attributes, every method of |
110 | | -//! `clap::Arg` in the form of `fn function_name(self, &str)` can be used |
111 | | -//! through specifying it as an attribute. The `name` attribute can be used |
112 | | -//! to customize the `Arg::with_name()` call (defaults to the field name in |
113 | | -//! kebab-case). |
114 | | -//! For functions that do not take a `&str` as argument, the attribute can be |
115 | | -//! wrapped in `raw()`, e. g. `raw(aliases = r#"&["alias"]"#, next_line_help = "true")`. |
| 113 | +//! Then, each field of the struct not marked as a subcommand |
| 114 | +//! corresponds to a `clap::Arg`. As with the struct attributes, every |
| 115 | +//! method of `clap::Arg` in the form of `fn function_name(self, |
| 116 | +//! &str)`, `fn function_name(self, bool)` or `fn function_name(self, |
| 117 | +//! usize)` can be used through specifying it as an attribute with a |
| 118 | +//! literal value. The `name` attribute can be used to customize the |
| 119 | +//! `Arg::with_name()` call (defaults to the field name in |
| 120 | +//! kebab-case). For functions that do not take an atomic literal as |
| 121 | +//! argument, the attribute can be wrapped in `raw()`, e. g. |
| 122 | +//! `raw(aliases = r#"&["alias"]"#, possible_values = r#"&["fast", |
| 123 | +//! "slow"]"#)`. |
116 | 124 | //! |
117 | 125 | //! The type of the field gives the kind of argument: |
118 | 126 | //! |
|
0 commit comments