@archivistnerd/bargs

0.1.4 • Public • Published

node-bargs

npm version

Archivist Nerd's bargs: Simple tool for command line interfaces

helps you build interactive command line tools by parsing arguments and generating an elegant user interface. (like a less useful version of yargs)

Reason for bargs instead of the bettter yargs?

bargs is smaller, less files, for simple command line tools yargs is WAYYY more powerful, more options, more cool :) yargs even has an awesome icon.

Installation

npm install -g @archivistnerd/bargs

Example

let bargs = require('@archivistnerd/bargs')
  ;
bargs
      .command('serve [port] [host]', 'Serve Local Path',
              (args)=>{}
            , [
                { name: 'port',      type: 'number', default: '8080',      describe: 'Port to listen on' },
                { name: 'host',      type: 'string', default: '127.0.0.1', describe: 'Host Address' },
                { name: 'path',      type: 'string', default: './',        describe: 'Local Path to serve' },
                { name: 'cacheFile', type: 'string',                       describe: 'cache filename' },
              ]
            )

      .command('validate', 'validate local path', (args)=>{
        // this command has no arguments
      })
      // test for option
      .option('burp', 'display "burp"', (args)=>{
        console.log('burp')
      }
      // default Command
      .command('$ [argument]', 'display argument', (args)=>{
        if ( args.argument !== undefined){
          bargs.displayHelp()
          return false;
        }
        console.log( args.argument )
      }
      , [ { name: 'argument', type: 'string', describe: 'argument' } ]
      )
      // display help if no commands are executed
      .help()
      ;

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @archivistnerd/bargs

Weekly Downloads

3

Version

0.1.4

License

MIT

Unpacked Size

10.9 kB

Total Files

4

Last publish

Collaborators

  • archivistnerd