Skip to content

Commit

Permalink
Merge pull request #5887 from epage/positional
Browse files Browse the repository at this point in the history
docs: Clarify the default state of an Arg/field
  • Loading branch information
epage authored Jan 20, 2025
2 parents f89134d + 0a73271 commit e01e2b9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
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

0 comments on commit e01e2b9

Please sign in to comment.