| .. | ||
| flag | ||
| flag.ts | ||
| input.ts | ||
| mod.ts | ||
| options.ts | ||
| readme.md | ||
-/arg
very simple argument parser
Usage:
import { bool, int, parse_args, str } from "-/arg/mod.ts";
const [args, flags] = parse_args({
action: {
type: str,
short: "a",
},
verbose: {
type: bool,
short: "v",
fallback: false,
},
});
node script.js -a hello --action next meow
{
flags: { action: [ "next", "hello" ], verbose: [ false ] },
args: [ "meow" ],
}
returns args and flags. flags are always an array.
if flags are provided more than once, the last ones appear first in the array.
the first array item therefore is always the last flag provided. this is useful
e.g. when aliasing a script built with -/arg with default flags.