0.0.13 • Published 4 months ago

tin-args v0.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

LICENSE npm version GitHub code size in bytes npm bundle size npm GitHub commit activity

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 adding re prefix.
    e.g - "re/\\.(j|t)s$/g"

  • yarn test -re "re/\\.(j|t)s$/g"

0.0.13

4 months ago

0.0.10

7 months ago

0.0.11

7 months ago

0.0.12

7 months ago

0.0.9

7 months ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago