npm

actionline

0.0.2 • Public • Published

actionline

actionline is a framework to help you make command line apps by providing:

  • automatic routing of commands.

  • providing commands with input data.

  • strict type system thanks to isaacs 'nopt' module.

  • sub commands have their own options and arguments ala git.

  • helpful defaults and warnings

  • color support like app.log('hey', 'red');

an example application:

var actionline = require('actionline'),
app = new actionline;

app.prompt('>>', 'green');

app.cmd('greet', {
  args: { "name": [String] },
  opts: { "smile": [Boolean] },
  func: function (input) {
    input.smile ?
    app.log('hello ' + input.name + '! :)')():
    app.log('hello ' + input.name)();
  },
    'rudely': {
      opts: { 'cake': [Boolean] },
      func: function (input) {
        if (input.cake) app.log('OH, HI, THANKS, BYE')();
        if (!input.cake) app.log('Oh,......')();
      }
    }
});
                                                                                                                                                                
// node example.js

>> greet faisal
hello faisal
>> greet faisal --smile
hello faisal! :)
>> greet
This command requires the argument(s): name
>> greet rudely
Oh,......
>> greet rudely --cake
OH, HI, THANKS, BYE

Things I want to add:

  • User-definable behaviours and errors, overriding the defaults.

  • Self-documentation via command.desc descriptors.

  • An instantiation method for before the app is booted.

  • CLI mode, since I'm parsing an array anyways thats like argv.

  • A JSON file store for persistance.

  • A views method which allows numbering/lettering onscreen data ala Earthquake.gem

  • An optional splash screen with ASCII text.

  • An alternative API, the constant curly braces and commas are annoying.

Readme

Keywords

none

Package Sidebar

Install

npm i actionline

Weekly Downloads

1

Version

0.0.2

License

none

Last publish

Collaborators

  • faisdotal