New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

clitoolkit

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clitoolkit

The command line toolkit

latest
Source
npmnpm
Version
0.0.14
Version published
Weekly downloads
26
420%
Maintainers
1
Weekly downloads
 
Created
Source

clitookit

The command line toolkit

###Installation

npm install clitoolkit

###Quick Start

File /bin/test:

#!/usr/bin/env node

var clitoolkit = require('clitoolkit');

//initial other command line tools
clitoolkit.init({
    version: 1.0.1,
    plugin: [
        'clitoolkit-plugin-a',
        'clitoolkit-plugin-b'
    ]
}, process.argv);

Plugin clitoolkit-plugin-a(clitoolkit-plugin-a/main.js):

module.exports = function(PluginAPI){
    PluginAPI.register('a', 'command a description', [{
            sample: '-d, --dest <names>',
            desc: 'dest files',
            defVal: 'dest'
        }, {
            sample: '-c, --config <names>',
            desc: 'set config file',
        }], function(commander, progArg){
        console.log('command a running...');
    });
};

Plugin clitoolkit-plugin-b(clitoolkit-plugin-b/main.js):

module.exports = function(PluginAPI){
    PluginAPI.register('b', 'command b description', [{
            sample: '-o, --ok <names>',
            desc: 'OK!!!'
        }, {
            sample: '-i, --info <names>',
            desc: 'command info',
        }], function(commander, progArg){
        console.log('command b running...');
    });
};

Execute the command /bin/test:

#show the usage of command test
test --help
#show the usage of command a
test a --help
#execute the command a
test a -d -c
#show the usage of command b
test b --help
#execute the command b
test b -oi

###Init API Options

  • opt: type-> Object the configration
    • version: type-> String the command version
    • pluginBase(optional): type-> String the plugin root path
    • plugin: type-> Array the clitoolkit plugins. if can not find the plugin in pluginBase clitoolkit will find node_modules which have the same name with the target plugin.
  • proArgv: type-> Array the progress's arguments(process.argv)

###Plugin

  • create a plugin for extend the command
  • plugin is a folder contains a main.js
  • main.js should exports a function that with a PluginAPI arguments
  • you can use PluginAPI to register a new command

Example:

module.exports = function(PluginAPI){
    PluginAPI.register(cmd, desc, options, action);
};

####PluginAPI

#####register(name, desc, option, action)

  • name: type-> String command name
  • desc: type-> String description
  • option: type-> Array command options
    • sample: type-> String command sample, e.g.: '-d, --dest '
    • desc(optional): type-> String option description
    • defVal(optional): type-> any the default value
  • action: type-> function eval this function when the command trigger

Keywords

toolkit

FAQs

Package last updated on 08 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts