Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/avil13/arg
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/avil13/arg
- Owner: avil13
- Created: 2020-03-29T15:00:09.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T16:30:09.000Z (almost 2 years ago)
- Last Synced: 2024-03-21T23:43:57.787Z (8 months ago)
- Language: TypeScript
- Size: 1.5 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### avil13/arg
NodeJS package for simple use arguments in cli.
example:
```bash
# bash
npm install @avil13/arg
``````ts
import { Arg } from '@avil13/arg';const arg = new Arg();
```
Further, "app" is the name of your application.```ts
// app --name Leo
arg.val('name'); // => Leo
```
```ts
// app --name Leo --day 1 --show --list hello world
arg.val.str('name'); // => Leo
arg.val.num('day'); // => 1
arg.val.bool('show'); // => true
arg.val.arr('list'); // => ['hello', 'world']
```# Read prepared params
```ts
import { Arg, IArgParamList } from '@avil13/arg';const arg = new Arg();
const cliArgs: IArgParamList = {
browser: {
type: 'string',
alias: 'b',
default: 'chrome',
description: 'Browser type',
},
};arg.params(cliArgs);
```# Create property
```ts
// default value: true
arg.param(`name,alias`, true, 'some description');// no default value
arg.param(`name,alias`, null, 'some description');
```# Use flag
```ts
const params: IArgParamList = {
add: {
flag: true, // arguments as flag
type: 'array',
default: ['.'],
description: 'Add alias by path',
},
};arg.params(params);
// node script.js add path/to/folder options
arg.val.arr('add') // => ['path/to/folder', 'options']```