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

cmd-liner

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cmd-liner

A command line utility library to make it easier to make command line tools.

latest
Source
npmnpm
Version
1.0.31
Version published
Maintainers
1
Created
Source

cmd-liner

Node.js library to help build awesome command line tools.

Installation

$ npm install cmd-liner

Features

  • Hierarchical (nested) commands.
  • Easily provide documentation for every one of the commands.
  • Handle errors when you want to.

Quick Start

var cmdliner = require('cmd-liner');

Now you need to create your commands object.

var commands = {};
commands.say = {
  action: function(cmd) {
    console.log('I say ' + cmd.args[0]);
  },
  argsCount: 1,
  desc: "A good description for the command 'say' :D"
};
commands.command2 = {
  commands: {
    is: function(optimist) {
      console.log('I can use optimist to parse arguments');
    }
  },
  nohandler: function() { console.error('No handler for this command :(')); }
}

Then you can initialize the command liner.

cmdliner.init(commands);

Take a look at https://github.com/substack/node-optimist. Every 'action' will be called with the instance of 'optimist' so you can parse arguments and create aliases. If your requirement needs no such thing, don't worry about it.

To-Do

  • Allow non-dashed parameters. (like 'echo $arg0')
  • More code examples and documentation

Keywords

parser

FAQs

Package last updated on 10 Jul 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