Open novusnota opened 2 months ago
It may be time to consider moving to another CLI toolkit. Commander.js is quite nice
is there a native typescript cli parser?
is there a native typescript cli parser?
No — there's no argument parser in Node.js APIs and TypeScript doesn't add APIs on top. One just gets process.argv and has to start from there :/
What works - works, and it's not a pressing issue considering that leading dashes are much less likely to occur in the context of files than in the context of evaluating expressions after -e
/--expr
. So the 0 + ...
workaround is good enough for a while
Problem
For example, consider the following instruction:
The expected result would be
0
, but instead one gets an exit code 2 and the following:Notes
Did some research, and it's probably related to poorly resolved closed and unresolved stale issues regarding this case in
yargs-parser
, whichmeow
(our CLI toolkit) uses for parsing arguments. It may be time to consider moving to another CLI toolkit. Commander.js is quite nice and is rather friendly towards #446, see https://github.com/tj/commander.js/issues/2008 (or we'll just duplicate some flags here and there, no biggie)As a temporary (ha!) workaround one may just put
0 +
in front of any expression and remove the--
. Like so: