Home

Awesome

Vorpal - SetOrPrint

Build Status

A Vorpal.js extension for quickly creating commands which set a value, or print it if no argument was given. Think instant getters/setters for the console.

Installation

npm install vorpal-setorprint
npm install vorpal

Getting Started

const vorpal = (require('vorpal'))();
const vorpalSOP = require('vorpal-setorprint');

vorpal.use(vorpalSOP)
  .delimiter('vorpal-setorprint demo $')
  .show();

const sop = vorpal.sop;
const options = {foo: 'bar'};

sop.command('foo', options);
$ node ./myapp.js
vorpal-setorprint demo $ help foo

Usage: foo [options] [foo]


set or print foo

Options:

  --help  output usage information

vorpal-setorprint demo $ foo
bar
vorpal-setorprint demo $ foo qux
vorpal-setorprint demo $ foo
qux
vorpal-setorprint demo $

Usage

Adds a sop object to vorpal, which stores options and provides a command function.

command(key, obj[, options]): Adds a command to vorpal which either sets or prints a specific value. Returns the command object, just like vorpal.command does. This allows convenient chaining, e.g.

sop.command(key, obj)
  .alias('foobar')
  .description('I like trains.');

See the example here for a simple usage of all the options.

Options

The following options passed by vorpal.use(vorpalSOP, options) are used: