subcmd
Create CLI tools with subcommands
Last updated 5 years ago by asbjornenge .
BSD · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install subcmd 
SYNC missed versions from official npm registry.

subcmd

Create CLI tools with subcommands.
Hugely inspired by subcommand, but with a nested structure and support for usage information.
Based on minimist and cliclopts.

subcmd has a single nested structure of commands

{
    name : "",
    usage : "",
    options : [],
    command : function(args) {},
    commands : []
}

It can be a single command or nested as deep as you want.

Install

npm install --save subcmd

Use

require('subcmd')({
    name : 'ls',
    usage : 'Usage: ls [OPTIONS]',
    options : [], /* cliclopts options */
    command : function(args) { /* do the ls thing */  },
    commands : [{
        name : 'foo',
        usage : 'Usage: ls foo [OPTIONS]',
        options : [],
        command : function(args) { /* do the ls foo thing */ },
        commands : []
    }]
},{
    autoHelp : true
})(process.argv.slice(2))

Options

{
    autoHelp : <bool>  // Print usage info and quit if -h or --help (default false)
}

Changelog

1.0.1

  • Added missing deps :see_no_evil:

1.0.0

  • Initial release :tada:

Current Tags

  • 1.0.1                                ...           latest (5 years ago)

2 Versions

  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (0)
None

Copyright 2014 - 2016 © taobao.org |