https://github.com/el1s7/getarg
CLI Args parser for Node/JS
https://github.com/el1s7/getarg
Last synced: about 2 months ago
JSON representation
CLI Args parser for Node/JS
- Host: GitHub
- URL: https://github.com/el1s7/getarg
- Owner: el1s7
- Created: 2022-06-15T14:06:03.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-26T16:41:48.000Z (almost 3 years ago)
- Last Synced: 2025-04-03T01:34:37.712Z (about 2 months ago)
- Language: JavaScript
- Size: 26.4 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Simple and fast CLI args parser for Node
### Install
`npm i getarg`#### Basic usage:
```javascript
import getArgs from 'getarg';//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'] //dependent parameters
alias: "f"
}
output:{
help: "Another helpful message",
required: true,
type: "string", //supported: number/json/any
alias: "o",
}
},{
usage: "Usage: myapp.js " //customize help header
});console.log(args);
```#### Example Run
```bash
> node cli.js -f ./file.js --output=./out.js{
file: "./file.js",
output: "./out.js"
}```
#### Example Info/Error:
```bash
> node cli.js --file[!] The paramater '--file' is not a string.
Usage: myapp.js
--file/-f [required] Another helpful message
--output/-o [required] A helpful message
```