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
program
.command('list')
.description('lists all objects')
.options('--name <name>', 'filter by name')
.action(function (options) {
// Program prints "filter enabled", even if user does not provide a value.
console.log(options.name ? 'filter enabled' : 'filter disabled');
})
The options object is not a raw property bag of the command line options, it is an object with some functions defined on it, one of which seems to be name, another is parent.
I feel like the API should be changed so there aren't hidden mines under certain option names -- or, at least, the documentation should make it clear what option names will conflict with these special API functions.
The text was updated successfully, but these errors were encountered:
I have opened a Pull Request which allows storing option values separately rather than as command properties (access using .opts()), and passes the options (rather than the command) to the action handler.
Take this simple program:
The
options
object is not a raw property bag of the command line options, it is an object with some functions defined on it, one of which seems to bename
, another isparent
.I feel like the API should be changed so there aren't hidden mines under certain option names -- or, at least, the documentation should make it clear what option names will conflict with these special API functions.
The text was updated successfully, but these errors were encountered: