ArgParser.add

add :: fn (_parser: Parser, short: string, long: string, help: string, handler: HandlerFn)

Add new argument specified by short and long name to be recognised by parser. The argument description can be specified as help. handler function is called every time parser hits this argument (short or long name match). Argument name must be unique name starting with -. Help command (as -h or –help) is added by default.

Example

ArgParser.add(parser,
    "-d", // short name.
    "--debug", // long name.
    "Enable debug mode.", // Help text.
    &fn (parser: ArgParser.Parser, args: []string, ctx: *ArgParser.Ctx) (s32, Error) {
        a: *MyArgs = auto ctx;
        a.is_debug = true;
        return 1, ok(); // One argument parsed ('-d' or '--debug')
    });

Declared in: arg_parser.bl