0.6.0 • Published 4 years ago
largs v0.6.0
largs
Light weight args, command line parser
Simple cli arguments configuration and parsing with minimal dependencies.
The API has a similar feel to Yargs but largs has a limited feature set.
Requires Node 10+
Install
npm install largs --save
yarn add largsUsage
Create an .option - ./script --option value -s short
or .positional - ./script one two
or a sub .command that supports all the same largs setup - ./command run --option value
and then .run() to process and return the options in a simple object
Options
Shortcut Options config setup
//import Largs from 'largs'
const { Largs } = require('largs')
const args = Largs.run({
  first: { short: 'f', required: true },
  second: { short: 's', long: 'two', type: 'integer', default: 1 },
  command_bork: {
    onlyhere: { type: String },
  }
})
console.log(args.bork.onlyhere) // => 'chef'For functional setup
//import largs from 'largs'
const { largs } = require('largs')
largs.option('firstthing')
    .short('f')
    .required()
largs.option('otherthing')
    .short('s')
    .long('two')
    .type('integer')
    .default(1)
largs.command('bork')
    .option('onlyforbork')
        .type('string)
largs.positional('one')
    .type('enum', ['this'])
    .required()
const args = largs.run() // returns object representation of opts. `opts.largs`
console.log(args) // => { firstthing: "val", otherthing: "val", bork: { onlyforbork: 'yep' }, positional: [ 'one' ] }→ node app.js --two 22222 this
Error: Missing required arguments
 "--firstthing/-f" is required
→ node app.js -f one --two 22222
Error: 1 argument is required
→ node app.js -f one --two 22222 asdf
Error: Arg "1" was "asdf" but must be one of: this"
→ node app.js -f one --two 22222 this
{ options: { first: 'one', second: 22222 },
  positional: [ 'this' ],
  config:
   { firstthing:
      { name: 'firstthing',
        short: 'f',
        long: 'firstthing',
        description: undefined,
        help: undefined,
        group: '' },
     otherthing:
      { name: 'otherthing',
        short: 's',
        long: 'two',
        description: undefined,
        help: undefined,
        group: '' } } }API
About
largs is released under the MIT license.
Copyright 2019-2021 mhio
0.6.0
4 years ago
0.4.1
8 years ago
0.4.0
8 years ago
0.3.1
8 years ago
0.2.0
8 years ago
0.2.0-1
8 years ago
0.1.0
9 years ago
0.1.0-1
9 years ago
0.0.5
9 years ago
0.0.4
9 years ago
0.0.4-0
9 years ago
0.0.3
9 years ago
0.0.3-2
9 years ago
0.0.3-1
9 years ago
0.0.3-0
9 years ago
0.0.2
9 years ago
0.0.2-1
9 years ago
0.0.2-0
9 years ago
0.0.1
9 years ago
0.0.1-0
9 years ago