10.0.1 • Published 10 months ago

@keg-hub/args-parse v10.0.1

Weekly downloads
75
License
MIT
Repository
github
Last release
10 months ago

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
10.0.1

10 months ago

10.0.0

1 year ago

9.0.0

2 years ago

8.0.1

2 years ago

8.0.0

2 years ago

7.1.0

2 years ago

7.0.0

2 years ago

6.3.2

3 years ago

6.3.0

3 years ago

6.3.1

3 years ago

6.2.3

3 years ago

6.2.2

3 years ago

6.2.1

3 years ago

6.1.0

4 years ago

0.0.1

4 years ago