tin-args
v0.0.13
Published
Simple command line argument extraction script with no complicated feature
Downloads
25
Readme
tin-args
Simple command line argument extraction script with no complicated feature
arg-test.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<typeof getExtraArgs<TArgs>>}
*/
const params = getExtraArgs({ prefex: "-" });
console.log(params);
- run
arg-test.js
with node
$ 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 addingre
prefix.
e.g -"re/\\.(j|t)s$/g"
yarn test -re "re/\\.(j|t)s$/g"