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
Just stumbled on this today… Would it not be better for the code to first check that there exists at least one purely numeric argument defined for the action or globally, before assuming that the - parameter is in fact an option?
In my case, it's a option to an "action" which is getting confused:
program.command('readloadsurvey <num> [start] [end]').description('read load survey <num> starting at record <start>').option('--search-ts','Search by time-stamp').action((num,start,end,options)=>{/* … etc… */});
Here, there is no option that matches the regex ^-\d$; therefore, an option like -1 cannot be anything but a negative number. In fact, there isn't even any "short form" arguments defined anywhere, so it'd be nice to be able to disable this, as the "feature" if possible. I can see it being ambiguous if I had defined any options matching this form, but here, that is not the case so it'd be better to assume "this is a number" rather than "this is an option".
Commander does not currently treat numbers as special. It is a little appealing, but this has not come up very often and would be a special case in the quite complicated parsing, so my first reaction is unlikely.
If you are interested in gathering more feedback, please open a new issue.
Activity
SomeKittens commentedon Jun 19, 2015
In this case you'd use the double hyphen
--to end option parsing.ciceropablo commentedon Jun 19, 2015
Ok!
Documentation about it (literal args)?
SomeKittens commentedon Jun 19, 2015
That's a general CLI thing not specific to commander
sjlongland commentedon Feb 23, 2021
Hi,
Just stumbled on this today… Would it not be better for the code to first check that there exists at least one purely numeric argument defined for the action or globally, before assuming that the
-parameter is in fact an option?In my case, it's a option to an "action" which is getting confused:
Here, there is no option that matches the regex
^-\d$; therefore, an option like-1cannot be anything but a negative number. In fact, there isn't even any "short form" arguments defined anywhere, so it'd be nice to be able to disable this, as the "feature" if possible. I can see it being ambiguous if I had defined any options matching this form, but here, that is not the case so it'd be better to assume "this is a number" rather than "this is an option".shadowspawn commentedon Feb 23, 2021
Commander does not currently treat numbers as special. It is a little appealing, but this has not come up very often and would be a special case in the quite complicated parsing, so my first reaction is unlikely.
If you are interested in gathering more feedback, please open a new issue.
Related: #61