Skip to content

Commit

Permalink
docs(derive): Acknowledge Vec<Vec<T>>
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jul 24, 2024
1 parent 5efa52a commit 6b18d77
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/_derive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,17 @@
//!
//! `clap` assumes some intent based on the type used:
//!
//! | Type | Effect | Implies |
//! |---------------------|--------------------------------------|-------------------------------------------------------------|
//! | `()` | user-defined | `.action(ArgAction::Set).required(false)` |
//! | `bool` | flag | `.action(ArgAction::SetTrue)` |
//! | `Option<T>` | optional argument | `.action(ArgAction::Set).required(false)` |
//! | `Option<Option<T>>` | optional value for optional argument | `.action(ArgAction::Set).required(false).num_args(0..=1)` |
//! | `T` | required argument | `.action(ArgAction::Set).required(!has_default)` |
//! | `Vec<T>` | `0..` occurrences of argument | `.action(ArgAction::Append).required(false)` |
//! | `Option<Vec<T>>` | `0..` occurrences of argument | `.action(ArgAction::Append).required(false)` |
//! | Type | Effect | Implies | Notes |
//! |-----------------------|------------------------------------------------------|-------------------------------------------------------------|-------|
//! | `()` | user-defined | `.action(ArgAction::Set).required(false)` | |
//! | `bool` | flag | `.action(ArgAction::SetTrue)` | |
//! | `Option<T>` | optional argument | `.action(ArgAction::Set).required(false)` | |
//! | `Option<Option<T>>` | optional value for optional argument | `.action(ArgAction::Set).required(false).num_args(0..=1)` | |
//! | `T` | required argument | `.action(ArgAction::Set).required(!has_default)` | |
//! | `Vec<T>` | `0..` occurrences of argument | `.action(ArgAction::Append).required(false)` | |
//! | `Option<Vec<T>>` | `0..` occurrences of argument | `.action(ArgAction::Append).required(false)` | |
//! | `Vec<Vec<T>>` | `0..` occurrences of argument, grouped by occurrence | `.action(ArgAction::Append).required(false)` | requires `unstable-v5` |
//! | `Option<Vec<Vec<T>>>` | `0..` occurrences of argument, grouped by occurrence | `.action(ArgAction::Append).required(false)` | requires `unstable-v5` |
//!
//! In addition, [`.value_parser(value_parser!(T))`][crate::value_parser!] is called for each
//! field.
Expand All @@ -309,8 +311,9 @@
//! - To force any inferred type (like `Vec<T>`) to be treated as `T`, you can refer to the type
//! by another means, like using `std::vec::Vec` instead of `Vec`. For improving this, see
//! [#4626](https://github.com/clap-rs/clap/issues/4626).
//! - `Option<Vec<T>>` will be `None` instead of `vec![]` if no arguments are provided.
//! - `Option<Vec<T>>` and `Option<Vec<Vec<T>>` will be `None` instead of `vec![]` if no arguments are provided.
//! - This gives the user some flexibility in designing their argument, like with `num_args(0..)`
//! - `Vec<Vec<T>>` will need [`Arg::num_args`][crate::Arg::num_args] set to be meaningful
//!
//! ## Doc Comments
//!
Expand Down

0 comments on commit 6b18d77

Please sign in to comment.