commandpost
Version:
commandline option parser
38 lines (37 loc) • 1.15 kB
TypeScript
export default class Argument {
/** argument name */
name: string;
/** this argument is required */
required: boolean;
/** this argument is variadic */
variadic: boolean;
/**
* class of argument.
* ```
* cmd --path foo/bar buzz.txt
* ↑ this one!
* ```
* @param arg pass '<foo>'(required) or '[foo]'(optional) or '<foo...>'(required & variadic) or '[foo...]'(optional & variadic)
* @class
*/
constructor(arg: string);
/**
* parse args.
* build to opts.
*
* e.g. #1
* instance member: name=foo, required=true, variadic=false
* method arguments: opts={}, args=["foo!", "bar!"].
* opts are modified to { foo: "foo!" } and return ["bar!"].
*
* e.g. #2
* instance member: name=foo, required=false, variadic=true
* method arguments: opts={}, args=["foo!", "bar!"].
* opts are modified to { foo: ["foo!", "bar!"] } and return [].
*
* @param opts build target object
* @param args
* @returns {string[]} rest args
*/
parse(opts: any, args: string[]): string[];
}