subcmd

1.0.1 • Public • Published

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 🙈

1.0.0

  • Initial release 🎉

Readme

Keywords

Package Sidebar

Install

npm i subcmd

Weekly Downloads

2

Version

1.0.1

License

BSD

Last publish

Collaborators

  • asbjornenge