Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Clarify the default state of an Arg/field #5887

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clap_builder/src/builder/arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ impl Arg {
/// The name is used to check whether or not the argument was used at
/// runtime, get values, set relationships with other args, etc..
///
/// By default, an `Arg` is
/// - Positional, see [`Arg::short`] or [`Arg::long`] turn it into an option
/// - Accept a single value, see [`Arg::action`] to override this
///
/// <div class="warning">
///
/// **NOTE:** In the case of arguments that take values (i.e. [`Arg::action(ArgAction::Set)`])
Expand Down
2 changes: 1 addition & 1 deletion src/_derive/_tutorial/chapter_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//!
//! ### Positionals
//!
//! You can have users specify values by their position on the command-line:
//! By default, struct fields define positional arguments:
//!
//! ```rust
#![doc = include_str!("../../../examples/tutorial_derive/03_03_positional.rs")]
Expand Down
3 changes: 3 additions & 0 deletions src/_derive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@
//! ### Arg Attributes
//!
//! These correspond to a [`Arg`][crate::Arg].
//! The default state for a field without attributes is to be a positional argument with [behavior
//! inferred from the field type](#arg-types).
//! `#[arg(...)]` attributes allow overriding or extending those defaults.
//!
//! **Raw attributes:** Any [`Arg` method][crate::Arg] can also be used as an attribute, see [Terminology](#terminology) for syntax.
//! - e.g. `#[arg(num_args(..=3))]` would translate to `arg.num_args(..=3)`
Expand Down
2 changes: 1 addition & 1 deletion src/_tutorial/chapter_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//!
//! ### Positionals
//!
//! You can have users specify values by their position on the command-line:
//! By default, an [`Arg`] defines a positional argument:
//!
//! ```rust
#![doc = include_str!("../../examples/tutorial_builder/03_03_positional.rs")]
Expand Down
Loading