@keg-hub/args-parse

10.0.1 • Public • Published

argsParse

Parse command line arguments

Setup

Install It

  • With yarn
yarn add @keg-hub/args-parse
  • With npm
npm install @keg-hub/args-parse

Use It

See test examples

;(() => {

  const { argsParse } = require('@keg-hub/args-parse')
  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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
10.0.1915latest

Version History

VersionDownloads (Last 7 Days)Published
10.0.1915
10.0.00
9.0.0268
8.0.10
8.0.00
7.1.0532
7.0.00
6.3.20
6.3.10
6.3.00
6.2.30
6.2.20
6.2.11
6.1.01
0.0.10

Package Sidebar

Install

npm i @keg-hub/args-parse

Weekly Downloads

1,599

Version

10.0.1

License

MIT

Unpacked Size

54 kB

Total Files

34

Last publish

Collaborators

  • lktipton