https://github.com/jeffy-g/tiny-args
https://github.com/jeffy-g/tiny-args
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jeffy-g/tiny-args
- Owner: jeffy-g
- License: mit
- Created: 2022-05-16T18:08:20.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-07T12:21:34.000Z (over 1 year ago)
- Last Synced: 2024-01-07T13:30:05.361Z (over 1 year ago)
- Language: JavaScript
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://badge.fury.io/js/tin-args)



# tin-args
+ Simple command line argument extraction script with no complicated feature
+ arg-test.js
```js
const getExtraArgs = require("tin-args");/**
* @typedef TArgs
* @prop {RegExp} test a regex
* @prop {number} factor a number
* @prop {boolean} minify use minify?
* @prop {string[]} values some string values as array
* @prop {string[]} values2 some string values as array
* @prop {any[]} a mixed values
*//**
* will be:
* ```ts
* const params: TArgs & { args?: string[]; }
* ```
* @type {ReturnType>}
*/
const params = getExtraArgs({ prefex: "-" });
console.log(params);
```+ run `arg-test.js` with node
```shell
$ yarn test .git/* # OR npm run test -- .git/*
{
test: /(?<=reference path=")(\.)(?=\/index.d.ts")/,
factor: 123.5,
minify: true,
values: [ 'v0', 'v1', 'v2' ],
values2: [ 'v0', 'v1', 'v2' ],
a: [ 'value0', 100, true, /\r?\n/g ],
args: [
'.git/config',
'.git/description',
'.git/HEAD',
'.git/hooks',
'.git/index',
'.git/info',
'.git/logs',
'.git/objects',
'.git/packed-refs',
'.git/refs',
'.git/tortoisegit.data',
'.git/tortoisegit.index'
]
}
```## NOTE for `regex` param value
+ If you use js `regex` as a parameter, you should be sure to recognize it as a regex object by adding `re` prefix.
e.g - `"re/\\.(j|t)s$/g"`+ `yarn test -re "re/\\.(j|t)s$/g"`