dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

How to offer options that are applicable to all commands? #323

Open balupton opened 6 years ago

balupton commented 6 years ago

I'd like to offer options that are applicable to all commands. For instance, at a minimum, I'd like to do be able to do:

const vorpal = require('vorpal')()

vorpal
    .option('-o, --out <outPath>')
    .option('-c, --config <configPath>')
    .option('-e, --env <environment>')
    .option('-d, --debug [logLevel]')
    .option('-g, --global')
    .option('-f, --force')
    .option('--no-color')
    .option('--silent')
    .option('--skeleton <skeleton>')
    .option('--offline')

vorpal.parse(process.argv)

// do something with the options

// add the commands

vorpal.show()

Then I'd like to add the commands on later.

The use case here, is the ability to setup my application using the global configuration, then once the application is ready for input, and once all the apps plugins has extended vorpal with their own commands, then do the commands.

The application in question is docpad.

/cc https://github.com/docpad/docpad/issues/1048