Package Exports
- base-cli
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (base-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
base-cli 
Plugin for base-methods that maps built-in methods to CLI args (also supports methods from a few plugins, like 'base-store', 'base-options' and 'base-data'.
Adds a cli method to base for mapping parsed command line arguments existing base methods or custom functions.
The goal is to simplify the process of settings up command line logic for your base-methods application.
Install
Install with npm
$ npm i base-cli --saveUsage
var cli = require('base-cli');
var base = require('base-methods');
var app = base();
// register the `cli` plugin with [base-methods][]:
app.use(cli());API
This adds a cli object to base with the following (chainable) methods (base.cli.*):
.map()- .map: add mappings from command line flags/options to custom functions orbasemethods.alias()- .alias: similar tomapbut creates simple aliases. For example,alias('show', 'get')would invoke the.get()method when--showis passed on the command line.process()- .process: once all mappings are defined, passargvto.process()to iterate over the mappings, passingargvas context.
Example
var expand = require('expand-args');
var argv = require('minimist')(process.argv.slice(2));
var base = require('base-methods');
var cli = require('base-cli');
var app = base();
app.use(cli());
app.cli
.map('foo', function(key, val) {
app.get(key, val);
})
.map('bar', function(key, val) {
app.set(key, val);
})
app.cli.process(expand(argv));
// command line args:
//
// '--set=a:b --get=a'
//
// prints:
//
// 'a'
// base-methods plugins
Other useful plugins for base-methods:
- base-config: base-methods plugin that adds a
configmethod for mapping declarative configuration values to other 'base'… more | homepage - base-data: adds a
datamethod to base-methods. | homepage - base-methods: Starter for creating a node.js application with a handful of common methods, like
set,get,… more | homepage - base-options: Adds a few options methods to base-methods, like
option,enableanddisable. See the readme… more | homepage - base-plugins: Upgrade's plugin support in base-methods to allow plugins to be called any time after init. | homepage
- base-store: Plugin for getting and persisting config values with your base-methods application. Adds a 'store' object… more | homepage
Tests
Running tests
Install dev dependencies:
$ npm i -d && npm testCoverage
Statements : 100% (13/13)
Branches : 100% (2/2)
Functions : 100% (4/4)
Lines : 100% (12/12)Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Author
Jon Schlinkert
License
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on October 28, 2015.