Sergey Organov [off-list ref] writes:
quoted
I am curious as to why you say that flags with optional arguments are
considered bad practice.
As far as I can tell, the core problem with such options is that generic
options parsing code can't tell if in "--option value" "value" is an
argument to "--option", or separate argument, that in turn may lead to
very surprising behaviors and bugs.
Another one and half reasons are
* Can there be two or more such options used on a single command
line? Unless we limit the command line and say "such an option
can appear only at the end of options and without any non option
arguments" (the latter is what you said above), we'd end up with
a system that cannot be explained to casual users.
* What about short-form of option? Is "-abc" asking for three
options "-a", "-b", and "-c"? Or is it "-a" option that takes
optional argument "bc"?
There are some advices we give in "git help cli" to our users, which
we shouldn't have to have given if we rejected flags with optional
arguments in our commands.
Thanks.