clef-parse
The argv parser behind cleffa and clefairy.
Usage
As a node.js library
import { parseArgv } from "clef-parse";
const result = parseArgv([
"--bundle",
"--input",
"index.js",
"--output",
"bundle.js",
"-v",
]);
console.log(result);
const result2 = parseArgv(
["--bundle", "--input", "index.js", "--output", "bundle.js", "-v"],
{
bundle: Boolean,
input: String,
output: String,
v: Boolean,
}
);
console.log(result2);
import { Path } from "clef-parse";
const result3 = parseArgv(
["--bundle", "--input", "index.js", "--output", "bundle.js", "-v"],
{
bundle: Boolean,
input: Path,
output: Path,
v: Boolean,
}
);
console.log(result3);
See the TypeScript types in the source code for more information.
As a CLI tool
$ npm install -g clef-parse
$ clef-parse one two --three-four=five
{
"options": {
"threeFour": "five"
},
"positionalArgs": [
"one",
"two"
]
}
You can't specify hints with the CLI tool.
License
MIT