You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support for short options with numeric values, e.g, -p80 #60
As for the short option -p80, long reply. My opinion. 😄
I do not think treating numbers as special for combining with short options is the correct high level approach. It is tempting and it is more familiar, but it is opinionated and breaks some other cases.
In particular, digits are valid short flags. If p is a flag then expanding -p1 to -p-1 is self consistent.
One affordance that supporting (any) value directly following a short option allows is supplying negative numbers or other values starting with a dash. So if v expects a value, you can enter -v-123 or -v--warnings. I think of this as the same affordance we have with long options and using =, --value=-123 or --value=--warnings.
I would prefer to have no support for trailing values than treat numbers specially in this regard. Then we still have a simple self-consistent story. We support grouping short flags. We do/don't support trailing values. No special cases.
I completely agree that if i do -pa or -p1, the only two options for both should be equivalent to either -p -a/-p -1 unconditionally, or, -p a/-p 1 iff a and 1 are not configured as options and also -p is configured as an option with a value.
(Small nit, I disagree with iff a and 1 are not configured as options but save that discussion for if we actually head towards support for trailing values!)
Activity
ljharb commentedon Feb 6, 2022
With one dash or two? With one, I’d expect it’s short for
-p 80bcoe commentedon Feb 6, 2022
what should the behavior with two dashes be
--p80?ljharb commentedon Feb 6, 2022
A long option named “p80”, only.
shadowspawn commentedon Feb 6, 2022
As per previous comment, I think
--p80is a usage of a long option namedp80.shadowspawn commentedon Feb 6, 2022
As for the short option
-p80, long reply. My opinion. 😄I do not think treating numbers as special for combining with short options is the correct high level approach. It is tempting and it is more familiar, but it is opinionated and breaks some other cases.
In particular, digits are valid short flags. If
pis a flag then expanding-p1to-p-1is self consistent.One affordance that supporting (any) value directly following a short option allows is supplying negative numbers or other values starting with a dash. So if
vexpects a value, you can enter-v-123or-v--warnings. I think of this as the same affordance we have with long options and using=,--value=-123or--value=--warnings.I would prefer to have no support for trailing values than treat numbers specially in this regard. Then we still have a simple self-consistent story. We support grouping short flags. We do/don't support trailing values. No special cases.
ljharb commentedon Feb 6, 2022
I completely agree that if i do
-paor-p1, the only two options for both should be equivalent to either-p -a/-p -1unconditionally, or,-p a/-p 1iffaand1are not configured as options and also-pis configured as an option with a value.shadowspawn commentedon Feb 6, 2022
(Small nit, I disagree with
iff a and 1 are not configured as optionsbut save that discussion for if we actually head towards support for trailing values!)ljharb commentedon Feb 7, 2022
What i mean is, with zero config, I’d expect them to all be considered as options, not values.
shadowspawn commentedon Mar 27, 2022
Support for trailing values for short options has landed, so current behaviour is: