1.1.5 • Published 1 year ago

@digitalbranch/get-args v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

getArgs

Nodejs package for getting commandline arguments.

Usage

const { getArgs } = require('get-args')

/* Choose a delimiter for defining the options on the commandline. */

const delimiter = '--'
const args = getArgs(delimiter)

When parsing the arguments it will do the following:

--name Mike -> name: "Mike" - argument value is of type string

--age 20 => age: 20 - argument value is of type integer

--amount 20.95 => amount: 20.95 - argument value is of type float

--hobbies painting, "playing guitar" => hobbies: [ "painting", "playing guitar" ] - argument value is of type
string[]

or without comma's

--hobbies painting "playing guitar" => hobbies: [ "painting", "playing guitar" ] - argument value is of type
string[]

--booleanValue => booleanValue: true - argument value is of type boolean
node myscript.js --name Mike --age 20 --hobbies reading, writing, executing --noJoke

Will result in

{
  name: 'Mike',
  age: 20,
  hobies: ['reading', 'writing', 'executing'],
  noJoke: true
}
1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago