Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support more than one level of subcommands #63

Closed
balupton opened this issue Jun 6, 2012 · 12 comments
Closed

Support more than one level of subcommands #63

balupton opened this issue Jun 6, 2012 · 12 comments

Comments

@balupton
Copy link

balupton commented Jun 6, 2012

Right now we can do this:

program = require('commander')

program
    .version('0.0.1')

program
    .command('plugin-create <name>')
    .description('create plugin')

program
    .command('plugin-delete <name>')
    .description('delete plugin')

which results with:


  Usage: woodchuck.js [options] [command]

  Commands:

    plugin-create <name>
    create plugin

    plugin-delete <name>
    delete plugin

  Options:

    -h, --help     output usage information
    -V, --version  output the version number

But we can't do this:

program = require('commander')

program
    .version('0.0.1')

program
    .command('plugin create <name>')
    .description('create plugin')

program
    .command('plugin delete <name>')
    .description('delete plugin')

which results with:

  Usage: woodchuck.js [options] [command]

  Commands:

    plugin <name>
    create plugin

    plugin <name>
    delete plugin

  Options:

    -h, --help     output usage information
    -V, --version  output the version number
@balupton
Copy link
Author

balupton commented Jun 6, 2012

Possibly related to #1

@tj
Copy link
Owner

tj commented Jun 6, 2012

yup this is a really old uncompleted thing but the "infrastructure" is there

@serby
Copy link

serby commented Jun 7, 2012

+1 this would be handy

@goto100
Copy link

goto100 commented Aug 28, 2012

this is useful, like "git remote". "git remote add", "git remote rm"

@tj
Copy link
Owner

tj commented Aug 29, 2012

I had to implement this for component(1), and honestly I think it's cleaner to just do it the git way, via which and execute component-install, component-create etc. However that being said it would be possibly nice to build that into commander or something more convenient

@Grigore147
Copy link

Did anyone work on this? Would be great to have it working like this.

@tj
Copy link
Owner

tj commented Sep 27, 2012

it's pretty simple if you're going with the executable-CMD approach:

var bin = 'component-' + cmd;
var proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] });

@Grigore147
Copy link

Hmm, sorry but I do not understand what you mean with this.

How this will allow something for ex.: app module install auth. So we could get it like so:

App.command('module install [name]')
  .description('install application module')
  .action(function(name) {
     //...
  });

@tj
Copy link
Owner

tj commented Sep 27, 2012

for example component install something invokes component-install something, this is how git and many others support commands, it's much more elegant IMO

@vjpr
Copy link

vjpr commented Mar 7, 2014

+1

I would like to be able to write app test server app test all app server, etc.

@diosney
Copy link

diosney commented Apr 4, 2014

+1 Any updates on this?

@tj
Copy link
Owner

tj commented Apr 25, 2014

closing because git-style is a lot more elegant than the .action stuff from before

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants