Closed my4ng closed 1 month ago
Thank you for your interest in this and the work that you put into this! However, we are not ready to make a breaking change at this time and we have not fully decided on a direction for this. I would instead recommend you propose your idea in the thread of #3030 and see where that goes. As this is too early for this PR and its unclear if this is the PR that we want, I'm going to go ahead and close this for now.
Fix #3030.
This PR enables restricting the short option to the
-oval
syntax with therequire_no_space
argument setting, and changesrequire_equals
to only affect the long option--option=val
(BREAKING CHANGE). This will allow compliance with the POSIX and GNU conventions as mentioned in the issue by setting bothrequire_no_space
andrequire_equals
to true:Here is an example help message that demonstrates this:
A specific real-world application that has motivated this is uutils/coreutils which aims to mirror the GNU version as closely as possible. However, their
date -I/--iso-8601
implementation, for example, accepts values that are not considered valid (e.g.date -I seconds
anddate -I=seconds
), and there is no possible workaround.The changes made to
require_equals
may break current applications that take a positional argument after an optional option-argument, e.g.Currently
cmd
would be treated as the second argument, but after the PR whererequire_equals
no longer works on short option, it will become the associated value to the first.Migration to the new major version (if this is merged) should complement
require_equals
withrequire_no_space
and replace-o=val
usage with-oval
, otherwise the associated value would become=val
as=
is parsed as part of the value.