From bf39b8d280452e54df4bc8863fc28fd4784f17cb Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 28 Nov 2022 09:49:09 -0600 Subject: [PATCH] docs(ref): Move flatten/subcommand to be under command attr Fixes #4505 --- src/_derive/mod.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/_derive/mod.rs b/src/_derive/mod.rs index f5da23632ba..b09cdf6b890 100644 --- a/src/_derive/mod.rs +++ b/src/_derive/mod.rs @@ -177,6 +177,18 @@ //! - `external_subcommand`: [`Command::allow_external_subcommand(true)`][crate::Command::allow_external_subcommands] //! - Variant must be either `Variant(Vec)` or `Variant(Vec)` //! +//! And for [`Args`][crate::Args] fields: +//! - `flatten`: Delegates to the field for more arguments (must implement [`Args`][crate::Args]) +//! - Only [`next_help_heading`][crate::Command::next_help_heading] can be used with `flatten`. See +//! [clap-rs/clap#3269](https://github.com/clap-rs/clap/issues/3269) for why +//! arg attributes are not generally supported. +//! - **Tip:** Though we do apply a flattened [`Args`][crate::Args]'s Parent Command Attributes, this +//! makes reuse harder. Generally prefer putting the cmd attributes on the +//! [`Parser`][crate::Parser] or on the flattened field. +//! - `subcommand`: Delegates definition of subcommands to the field (must implement +//! [`Subcommand`][crate::Subcommand]) +//! - When `Option`, the subcommand becomes optional +//! //! ### ArgGroup Attributes //! //! These correspond to the [`ArgGroup`][crate::ArgGroup] which is implicitly created for each @@ -214,16 +226,6 @@ //! - `env [= ]`: [`Arg::env`][crate::Arg::env] (needs [`env` feature][crate::_features] enabled) //! - When not present: no env set //! - Without ``: defaults to the case-converted field name -//! - `flatten`: Delegates to the field for more arguments (must implement [`Args`][crate::Args]) -//! - Only [`next_help_heading`][crate::Command::next_help_heading] can be used with `flatten`. See -//! [clap-rs/clap#3269](https://github.com/clap-rs/clap/issues/3269) for why -//! arg attributes are not generally supported. -//! - **Tip:** Though we do apply a flattened [`Args`][crate::Args]'s Parent Command Attributes, this -//! makes reuse harder. Generally prefer putting the cmd attributes on the -//! [`Parser`][crate::Parser] or on the flattened field. -//! - `subcommand`: Delegates definition of subcommands to the field (must implement -//! [`Subcommand`][crate::Subcommand]) -//! - When `Option`, the subcommand becomes optional //! - `from_global`: Read a [`Arg::global`][crate::Arg::global] argument (raw attribute), regardless of what subcommand you are in //! - `value_enum`: Parse the value using the [`ValueEnum`][crate::ValueEnum] //! - `skip [= ]`: Ignore this field, filling in with ``