cli icon indicating copy to clipboard operation
cli copied to clipboard

change the location of args and options.

Open xbsummer opened this issue 3 years ago • 1 comments

Checklist

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

What problem does this solve?

Another way of writing on the command line

Solution description

     old:   command [options ...] [arguments...]
 another:   command [arguments...] [options ...] 

example:
     old:   command test -d name=123 -d age=18 -d sex=MALE arg1 arg2 arg3 ....
 another:   command test  arg1 -arg2 arg3 ....  -d name=123  age=18 sex=MALE  #-arg2 not an option

from the example, you can see: the old way, each option can only be followed by one value, if there are multiple values, must be multiple -d options, If there is no -d option,multiple values may lead to inability to distinguish args. the another way, an option can be followed by multiple values, multiple values are separated by spaces, if the args are preceded by -, you can verify whether it is an option, until the first option is found, the front is all args

recommended to add a switch, which uses the old parsing mode by default, and use the new parsing mode if the switch is turned on。

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

xbsummer avatar Jul 08 '22 03:07 xbsummer

@xbsummer Thank you for taking the time to write this up ❤️ I hope I'm understanding correctly here, so please do say if I'm way off base 😅

Introducing an alternate parser continues to be a popular topic (e.g. https://github.com/urfave/cli/issues/1391), so I don't want to give you the impression that maintainers don't care. The attempts to take on this work so far haven't gone beyond the experimental phase, and feedback from those making such attempts has roughly been that the work is non-trivial (citations needed). All of that being said, I'm personally very interested in the possibility of building on top of a different parser library. Targeting the v3-dev-main branch will likely allow for greater change. Any chance you're up for trying something?

meatballhat avatar Jul 09 '22 14:07 meatballhat

Duplicate of #1113

dearchap avatar Oct 21 '22 19:10 dearchap