1.0.31 • Published 2 years ago

darg v1.0.31

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Parse CLI args for node

Install

npm i darg

Basic usage:

import getArgs from 'darg';

//Run without any options to get an object of all args supplied at runtime
const args = getArgs({
    file:{
        required: true,
        type: "string",
        help: "A helpful message",
        requires: ['output']
        alias: "f"
    }
    output:{
        help: "Another helpful message",
        required: true,
        type: "string", //supported: number/json/any
        alias: "o",
    }
},{
    usage: "Usage: myapp.js <command>" //customize help header
});

console.log(args);

Example Run

> node cli.js -f ./file.js --output=./out.js

{
    file: "./file.js",
    output: "./out.js"
}

Example Help:

> node cli.js

The paramater '--file' is required.

The paramater '--output' is required.

Usage: myapp.js <command>


--file/-f [required]            Another helpful message   

--output/-o [required]            A helpful message
1.0.31

2 years ago

1.0.3

2 years ago

1.0.21

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.9

2 years ago