Automatically defer subcommand initialization for derives #4959
Labels
A-derive
Area: #[derive]` macro API
C-enhancement
Category: Raise on the bar on expectations
M-breaking-change
Meta: Implementing or merging this will introduce a breaking change.
Milestone
Please complete the following tasks
Clap Version
4.3.3
Describe your use case
#4792 added deferred command initialization but no support exists yet for the derive API.
Describe the solution you'd like
Automatically defer all non-essential subcommand calls.
Alternatives, if applicable
No response
Additional Context
Automatic deferment would be a breaking change though we could make it opt-in through the remainder of 4.x
A rough sketch
Args
to havedefer_augment_args
Subcommand
to havedefer_augment_subcommand
#[command(defer = <bool>)]
magic attributefalse
in clap v4true
in clap v5, mark it as deprecateddefer = false
on a top-level container, always calldefer_augment_args
along withaugment_args
defer = true
on a top-level containerCommand::subcommand
andCommand::arg
callsdefer = true
on aflatten
,augment_args
only calls the same of its childrendefer = false
on aflatten
, deferaugment_args
until whendefer_augment_args
is calledThe text was updated successfully, but these errors were encountered: