|
291 | 291 | //!
|
292 | 292 | //! `clap` assumes some intent based on the type used:
|
293 | 293 | //!
|
294 |
| -//! | Type | Effect | Implies | |
295 |
| -//! |---------------------|--------------------------------------|-------------------------------------------------------------| |
296 |
| -//! | `()` | user-defined | `.action(ArgAction::Set).required(false)` | |
297 |
| -//! | `bool` | flag | `.action(ArgAction::SetTrue)` | |
298 |
| -//! | `Option<T>` | optional argument | `.action(ArgAction::Set).required(false)` | |
299 |
| -//! | `Option<Option<T>>` | optional value for optional argument | `.action(ArgAction::Set).required(false).num_args(0..=1)` | |
300 |
| -//! | `T` | required argument | `.action(ArgAction::Set).required(!has_default)` | |
301 |
| -//! | `Vec<T>` | `0..` occurrences of argument | `.action(ArgAction::Append).required(false)` | |
302 |
| -//! | `Option<Vec<T>>` | `0..` occurrences of argument | `.action(ArgAction::Append).required(false)` | |
| 294 | +//! | Type | Effect | Implies | Notes | |
| 295 | +//! |-----------------------|------------------------------------------------------|-------------------------------------------------------------|-------| |
| 296 | +//! | `()` | user-defined | `.action(ArgAction::Set).required(false)` | | |
| 297 | +//! | `bool` | flag | `.action(ArgAction::SetTrue)` | | |
| 298 | +//! | `Option<T>` | optional argument | `.action(ArgAction::Set).required(false)` | | |
| 299 | +//! | `Option<Option<T>>` | optional value for optional argument | `.action(ArgAction::Set).required(false).num_args(0..=1)` | | |
| 300 | +//! | `T` | required argument | `.action(ArgAction::Set).required(!has_default)` | | |
| 301 | +//! | `Vec<T>` | `0..` occurrences of argument | `.action(ArgAction::Append).required(false)` | | |
| 302 | +//! | `Option<Vec<T>>` | `0..` occurrences of argument | `.action(ArgAction::Append).required(false)` | | |
| 303 | +//! | `Vec<Vec<T>>` | `0..` occurrences of argument, grouped by occurrence | `.action(ArgAction::Append).required(false)` | requires `unstable-v5` | |
| 304 | +//! | `Option<Vec<Vec<T>>>` | `0..` occurrences of argument, grouped by occurrence | `.action(ArgAction::Append).required(false)` | requires `unstable-v5` | |
303 | 305 | //!
|
304 | 306 | //! In addition, [`.value_parser(value_parser!(T))`][crate::value_parser!] is called for each
|
305 | 307 | //! field.
|
|
309 | 311 | //! - To force any inferred type (like `Vec<T>`) to be treated as `T`, you can refer to the type
|
310 | 312 | //! by another means, like using `std::vec::Vec` instead of `Vec`. For improving this, see
|
311 | 313 | //! [#4626](https://github.com/clap-rs/clap/issues/4626).
|
312 |
| -//! - `Option<Vec<T>>` will be `None` instead of `vec![]` if no arguments are provided. |
| 314 | +//! - `Option<Vec<T>>` and `Option<Vec<Vec<T>>` will be `None` instead of `vec![]` if no arguments are provided. |
313 | 315 | //! - This gives the user some flexibility in designing their argument, like with `num_args(0..)`
|
| 316 | +//! - `Vec<Vec<T>>` will need [`Arg::num_args`][crate::Arg::num_args] set to be meaningful |
314 | 317 | //!
|
315 | 318 | //! ## Doc Comments
|
316 | 319 | //!
|
|
0 commit comments