@archivistnerd/bargs

Archivist Nerd's bargs Package

Usage no npm install needed!

<script type="module">
  import archivistnerdBargs from 'https://cdn.skypack.dev/@archivistnerd/bargs';
</script>

README

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