Skip to content

Make Command::args_overrides_self the default #4261

Open
@epage

Description

@epage

We had talked about swapping the default for 3.0 but punted.

When working on ArgAction during 3.2, I modeled it after Python's argparse which only supports overriding, making args_overrides_self the only behavior for the new actions.

When switching cargo to the new actions, some tests specifically checking for self-conflicts failed. This reminded me that in cargo 1.64.0, --target switched from a multiple_occurrences(false) to multiple_occurrences(true). This was a switch from an error case to a working case. If args_overrides_self had been on, it would have been a switch from a working case to a working case, being a change in working behavior.

We decided in 4.0.0 to defer a decision on the behavior and bring back args_overrides_self, making the new actions behave like the old ones,

So to summarize args_overrides_self(true)

  • Allows easy overriding of previous arguments, especially if args/aliases are involved
    • e.g. alias ls='ls -xyz' would be safe to repeat some of those flagd
  • Has compatibility hazards

So should we switch to it being on by default, only on, or maintain status quo?

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parsingArea: Parser's logic and needs it changed somehow.C-enhancementCategory: Raise on the bar on expectationsM-breaking-changeMeta: Implementing or merging this will introduce a breaking change.S-waiting-on-decisionStatus: Waiting on a go/no-go before implementing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @epage

        Issue actions

          Make `Command::args_overrides_self` the default · Issue #4261 · clap-rs/clap