import { ArgumentsContext } from './arguments-context'; import { ParserConfig } from './parser-config'; /** * Inject token for the arguments parser implementation * * @publicAPi */ export declare const ARGS_PARSER: unique symbol; /** * Interface describing the requirements for an implementation of the parsing provider, which evaulates the raw cli arguments * into a form that can be used to match and resolve commands/subcommands, as well as validate and bind cli options and parameters. * The default implementation is the `DefaultArgumentsParser`. * * @publicApi */ export interface ArgumentsParser { /** * Processes the raw cli arguments and returns a context from which commands/subcommands can matched and resolved. The context also * allows options and parameters to be validated and bound * @param rawArgs string array of raw cli arguments */ parse(rawArgs: string[]): ArgumentsContext; } /** * The default implementation of the argument parsing behavior, `ArgumentsParser`. The default behaviour provides the following * functionality: * - All arguments prefixed with -- or - are taken as options [*create value `-v` `--s`*] * - Arguments immediately after options, not prefixed with dashes, are taken as the option's value [create *--prod --name `my-name` value*] * - Options that do not have a preceeding value are taken as option flags and will have a value equal to true * - Where the same option is provided twice it will have an array value [*create `-v` name `-v` name2*] := ['name', 'name2'] * - Possible parameters are taken as arguments that are not an option or an option value [*`create` `value` -v --s my-name `value2`*] * - By default, possible commands are taken as all arguments before the first option [*`create` `value` -v --s my-name value2*] * - If the ParserConfig.allowCommandsAfterOptions is set to true then possible commands will be the same as possible parameters * * @publicApi */ export declare class DefaultArgumentsParser implements ArgumentsParser { private config; /** * Creates a new instance * @param config Parsing configuration for modifying the behavior */ constructor(config: ParserConfig); /** * Processes the raw cli arguments and returns a context from which commands/subcommands can matched and resolved. The context also * allows options and parameters to be validated and bound * @param rawArgs string array of raw cli arguments */ parse(rawArgs: string[]): ArgumentsContext; private addOption; /** * Returns a list of possible commands * @param commandsAfterOpts Whether commands are allowed after options * @param firstOptionIndex Index of the first option * @param remainingArgs Arguments that are not options or option values */ private getPossibleCommands; }