Commander.js: Default subcommand not possible in example

Created on 12 Nov 2015  路  8Comments  路  Source: tj/commander.js

In Example we have a bunch of subcommands listed, however there is no way to make any of them the default.

I've tried, for example, changing the final subcommand to .command('*', undefined, {isDefault: true}) however it seems to have no impact. Providing a description does worse: it causes file-* does not exist to be returned for either * or default.

Most helpful comment

Facing same problem. I have:

program.command('help', null, {isDefault:true})
  .description('display help information.')
  .action(function(){
    program.outputHelp();
  });

program.command('*', null, {noHelp:true})
  .action(function(cmd){
    console.error('unrecognized command: ' + cmd);
    program.outputHelp();
  });

noHelp is working as expected, while isDefault has no impact.

All 8 comments

Facing same problem. I have:

program.command('help', null, {isDefault:true})
  .description('display help information.')
  .action(function(){
    program.outputHelp();
  });

program.command('*', null, {noHelp:true})
  .action(function(cmd){
    console.error('unrecognized command: ' + cmd);
    program.outputHelp();
  });

noHelp is working as expected, while isDefault has no impact.

+1

Is this going to be looked at? It seems like https://github.com/tj/commander.js/blob/aaa447a8f0717771d0b021c27b709ef867c220e0/index.js#L169-L191 is being called three times. The first time it correctly finds the isDefault flag, the last two are undefined.

Is this package at all maintained anymore? This is really a critical issue and is still not fixed.

These days I'm using:

And a more popular alternative is:

The isDefault functionality is currently only supported for git-style subcommands. I am closing this issue in favour of #742 which identifies the limitation in the title.

I know this is a lot to ask but could you elaborate (provide a short example maybe?) what does it mean _git-style subcommands_? I am mighty confused...

@padcom
There is a section in the README, and example in the examples:
https://github.com/tj/commander.js#git-style-sub-commands
https://github.com/tj/commander.js/blob/master/examples/pm

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shadowspawn picture shadowspawn  路  3Comments

winys picture winys  路  5Comments

0505gonzalez picture 0505gonzalez  路  3Comments

akki005 picture akki005  路  5Comments

mtrabelsi picture mtrabelsi  路  3Comments