-
-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Lines 150 to 152 in 1cdf3e4
| // show main help if relied on "default" for multi-cmd | |
| if (argv.help) return this.help(!isSingle && !isVoid && name); | |
| if (argv.version) return this._version(); |
The early return here will break the following:
const prog = sade('cool-cli', true).version('1.0.0').describe('Some cool CLI.')
const {args} = prog.parse(process.argv, {lazy: true})
if (args.something) {
// do stuff
}This is inconsistent with the documentation:
Lines 638 to 653 in 1cdf3e4
| #### opts.lazy | |
| Type: `Boolean`<br> | |
| Default: `false` | |
| If true, Sade will not immediately execute the `action` handler. Instead, `parse()` will return an object of `{ name, args, handler }` shape, wherein the `name` is the command name, `args` is all arguments that _would be_ passed to the action handler, and `handler` is the function itself. | |
| From this, you may choose when to run the `handler` function. You also have the option to further modify the `args` for any reason, if needed. | |
| ```js | |
| let { name, args, handler } = prog.parse(process.argv, { lazy:true }); | |
| console.log('> Received command: ', name); | |
| // later on... | |
| handler.apply(null, args); | |
| ``` |
One solution may be to return:
{
args: [],
name: '',
handler: undefined,
helpOrVersion: true // indicates the user passed one of the options
}Metadata
Metadata
Assignees
Labels
No labels