-
Notifications
You must be signed in to change notification settings - Fork 1k
Show help for no command and handle unknown command #883
Copy link
Copy link
Closed
Labels
Description
I trouble to implement folliwng case:
- Show message
unknown commandif some unknnown command supplied - Show help if no command supplied.
To handle unknown command I use default command *, it works ok
.command({
command: '*',
handler: (argv) => {
if (argv._[0]) {
console.log('Unknown commmand', argv._[0])
}
}
})
.demand(1)But demand(1) here doesn't work in this case so If I supply no command nothing happens at all (it goes to * handler)
I tried to use yargs.showHelp() somewhere in '*' handler or just checking main argv
const argv = yargs...
if (!argv._[0]) {
yargs.showHelp()
}but it doesn't show help. All it shows:
Options:
--help Show help [boolean]
Reactions are currently unavailable