yaclip
v1.2.1
Published
Yet another command line parser (that supports subcommands)
Downloads
340
Readme
Yet another command line parser. This one supports subcommands though.
Usage
const parseCommandLine = require("yaclip");
const subcommands = [
{ name: 'subcommand', alias: "s", type: String, multiple: false},
]
const commands = [
{ name: 'command', alias: "c", type: String, multiple: false, subcommands},
{ name: 'other', alias: "0", type: String, multiple: false}
];
const arguments = parseCommandLine(commands);
console.log(arguments);
node example.js \
--command "This is the command" \
--subcommand "this goes in the subsection of command" \
--other "this is parsed nicely"
It has limitations, I built it for bounce.
Dash optionality
If you prefer your commands without dashes, specify option dashesAreOptional
to true
when instantiating the parser:
const arguments = parseCommandLine(commands, { dashesAreOptional: true });
console.log(arguments);
node example.js \
command "This is the command" \
--subcommand "this goes in the subsection of command" \
other "this is parsed nicely"