I didn't find a way to retrieve a flag from. For example if I run a command with --dry-run
, and I declare this like this:
I tried to debug the command argument but it doesn't really help, so I think it would be wiser to give you feedback :)
Here is the command argument, dry-run is present but for me, it would be not clean to retrieve it like this: command.options[0]
and I didn't find the type used in commander and your lib :(
Command {
commands: [],
options: [
Option {
flags: '--dry-run',
required: false,
optional: false,
mandatory: false,
negate: false,
long: '--dry-run',
description: 'Dry run the execution'
}
],
_execs: Set {},
_allowUnknownOption: false,
_args: [],
_name: 'update',
_helpFlags: '-h, --help',
_helpDescription: 'output usage information',
_helpShortFlag: '-h',
_helpLongFlag: '--help',
_noHelp: false,
_exitCallback: undefined,
_executableFile: undefined,
parent: Command {
commands: [ [Circular], [Command] ],
options: [],
_execs: Set {},
_allowUnknownOption: false,
_args: [],
_name: '01-actor-id-actor-type-index',
_helpFlags: '-h, --help',
_helpDescription: 'output usage information',
_helpShortFlag: '-h',
_helpLongFlag: '--help',
_noHelp: false,
_exitCallback: undefined,
_executableFile: undefined,
parent: Command {
commands: [Array],
options: [],
_execs: Set {},
_allowUnknownOption: false,
_args: [],
_name: 'migration',
_helpFlags: '-h, --help',
_helpDescription: 'output usage information',
_helpShortFlag: '-h',
_helpLongFlag: '--help',
_events: [Object: null prototype],
_eventsCount: 2,
rawArgs: [Array],
args: []
},
_description: 'A command to create the index',
_argsDescription: undefined,
_events: [Object: null prototype] {
'command:update': [Function: listener],
'command:rollback': [Function: listener]
},
_eventsCount: 2
},
_description: 'Update will create the index for actor id and type',
_argsDescription: undefined,
_events: [Object: null prototype] { 'option:dry-run': [Function] },
_eventsCount: 1
}