@svkeg/args-parse

0.0.1 • Public • Published

argsParse

Parse command line arguments

Setup

Install It

Add to your package.json

  "argsParse": "git+https://github.com/lancetipton/argsParse.git"

Use It

See test examples

;(() => {

  const { argsParse } = require('argsParse')
  const task = {
    options: {
      // Define required
      doo: {
        description: "dew the doo",
        require: true,
      },
      // Define defaults
      foo: {
        description: 'I am foo bar',
        default: 'bar'
      },
      baz: {
      // Define alias
        alias: [ 'zoo' ],
        description: 'The baz with bas',
      },
    }
  }
  
  const parsed = await argsParse({
    task,
    args: [ 'doo=f', '--zoo', 'bas', ],
  })
  
  expect(parsed.doo).toBe(false)
  expect(parsed.foo).toBe('bar')
  expect(parsed.baz).toBe('bas')

})()

Custom Config

  • Use the PARSE_CONFIG_PATH environment vairable to overwrite the path to the parse config
    • Path should be relative to the applications root directory
  • See default config
  • Custom Configs should match the keys within the default config
    • bools && environment

Readme

Keywords

Package Sidebar

Install

npm i @svkeg/args-parse

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

40.8 kB

Total Files

42

Last publish

Collaborators

  • lktipton