jawher / mow.cli

A versatile library for building CLI applications in Go
MIT License
872 stars 55 forks source link

Provide a way to mark options as un-ordered #93

Closed nim-nim closed 5 years ago

nim-nim commented 5 years ago

This is not a huge issue, just an annoyance

Right now the documentation states

Order between options and arguments is significant (-f and -g must appear before the SRC argument)

So I don't see how to specify a command like rm -fr DIR, where the option-to-argument ordering is not significant, and rm -fr DIR, rm -r DIR -f, rm -f DIR -r, rm DIR -fr are all acceptable and equivalent

Basically, one of my commands has generic options like -q | --quiet that do not require any special position on the command line.

The canonical way to write the command is

something sub [options] ORDERED_ARGS

But it is very common for users to backtrack in shell history, and that will position the cursor to the end of the command line, so they'd like to add/remove -q and other generic things there without having to move to a specific point in the command line.

I suppose I could specify the same optional option group before, between and after each argument, but that becomes mightily verbose and unreadable in --help, and you lose the possibility to specify inter-option constrains like “verbose and silent are incompatible, use at most one of them”

nim-nim commented 5 years ago

This is a duplicate of issue #64