parse-my-command
Version:
Parse argv with Commander.js without executing the command
30 lines (27 loc) • 1.21 kB
TypeScript
import { Command, OptionValues, OptionValueSource, ParseOptions } from 'commander';
declare const findMissingOptions: (command: Command, providedOptionsByCommand: Map<Command, OptionValues>) => Map<Command, Set<string>>;
type PartialParseResult = {
/**
* The command whose action will be executed
*/
matchedCommand: Command | undefined;
/**
* A map of commands to a set of missing options for that command
*/
missingOptions: Map<Command, Set<string>>;
/**
* A map of commands to the options provided for that command
*/
providedOptions: Map<Command, OptionValues>;
/**
* A map of commands to a map of option keys to the source of the option value
*/
providedOptionsSources: Map<Command, Map<string, OptionValueSource | undefined>>;
};
/**
* Partially parse argv for a command without executing the action. @see {@link Command.parse}
*
* @returns An object containing the matched command, the provided options, and the missing options.
*/
declare const partialParse: (command: Command, argv: readonly string[], options?: ParseOptions) => PartialParseResult;
export { type PartialParseResult, findMissingOptions, partialParse };