Skip to content

Allow flags to come after arguments #1950

@fiatjaf

Description

@fiatjaf

Checklist

  • Are you running the latest v3 release? The list of releases is here.
  • Did you check the manual for your release? The v3 manual is here.
  • Did you perform a search about this feature? Here's the GitHub guide about searching.

What problem does this solve?

cli -s file.txt and cli file.txt -s should work the same way because having to strictly type the flags before the arguments is annoying. Most unix utils allow flags after arguments so people are used to that pattern and a thing that is obviously a flag shouldn't be interpreted as an argument just because it comes after another argument.

Solution description

cli -s file.txt and cli file.txt -s should work the same way.
cli -s file.txt and cli --foo=bar file.txt -s -v --whatever=something should work the same way.

Describe alternatives you've considered

I've tried switching to other CLI frameworks, but they are all much worse than this except in this aspect.

I've tried frontporting a feature from v1 that reordered arguments manually before parsing them: #1928 (currently using this with a custom fork and replace).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/v3relates to / is being considered for v3status/triagemaintainers still need to look into this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions