Yargs: argv alternative

Created on 11 Jun 2017  路  3Comments  路  Source: yargs/yargs

Is there a method to call instead of the argv getter? In cases where the cli always requires a command(and each command has its handler already set), the argv called in the entry point will not be used, making the linter complain of unused expression.

A solution would be having a function run() or something like that at the end of the Yargs call chain, is there already such function?

Thanks

Most helpful comment

This should probably be closed now, in Yargs 9.0.0 you can call .parse() to get the same behaviour as .argv, but with a function call instead of a getter 馃帀 馃憦

All 3 comments

Running main program implicitly by invoking a getter is a side effect.
This is what all developers across the world should avoid.
Please, add an explicit method to run program, e.g. run() or parse().

This should probably be closed now, in Yargs 9.0.0 you can call .parse() to get the same behaviour as .argv, but with a function call instead of a getter 馃帀 馃憦

I was very confused when I was reading documentation with all those lines ending with .argv and it was never used. I guessed that I need to do something with the argv field value. Took me some time to figure out that side-effect happens when you access argv property.

Maybe documentation should be updated with .parse() instead of .argv?

Was this page helpful?
0 / 5 - 0 ratings