Commander.js: Show help when command is unknown

Created on 13 Jan 2017  路  3Comments  路  Source: tj/commander.js

Hello,

What would be the best way of printing help output when the command is unknown? E.g. program unknownCommand

Most helpful comment

@goldcaddy77 The issue with this is that the * still show in the help output

All 3 comments

This should work:

    program.on('*', function () {
      console.log('Unknown Command: ' + program.args.join(' '))
      program.help()
    })

It would be good to get this documented in the readme.

Answered

@goldcaddy77 The issue with this is that the * still show in the help output

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RoXioTD picture RoXioTD  路  4Comments

mtrabelsi picture mtrabelsi  路  3Comments

oknoorap picture oknoorap  路  4Comments

san-templates picture san-templates  路  5Comments

snitin315 picture snitin315  路  4Comments