Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

feature: mount commands into the ArgParser #64

Open
aoberoi opened this issue Jun 3, 2015 · 0 comments
Open

feature: mount commands into the ArgParser #64

aoberoi opened this issue Jun 3, 2015 · 0 comments

Comments

@aoberoi
Copy link

aoberoi commented Jun 3, 2015

I'd like to be able to modularize my code by command. in order to achieve this, i'd like a way for one file to be able to export a command, and then the top level file to require() that command and mount it into an ArgParser. finally the top level would call .parse() on the ArgParser instance.

illustration:

index.js

#!/usr/bin/env node

var parser = require('nomnom');
var exampleCommand = require('./cmds/example');

parser.mount(exampleCommand);

parser.parse();

cmds/example.js

var command = require('nomnom').command('example');

command
  .option('foo', {
    abbr: 'f'
  })
  .callback(function(opts) {
    console.dir(opts);
  })

module.exports = command;
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant