Commander.js: how to specify the required cli argument

I use the commander.js package to analyze command line arguments: I would like to make the flag non-optional, APIs and tests in git repo , not to mention the need to make the flag, but I usually need to hit the head with instructions.

Is this possible, and will the script reset if this requirement is not met?

+6
source share
1 answer

I think this is not supported by commander.js https://github.com/visionmedia/commander.js/issues/44

But you can do something similar in your program -

if (!program.myoption) throw new Error('--myoption required') 
+12
source

Source: https://habr.com/ru/post/970722/


All Articles