// Type definitions for dashdash 1.14 // Project: https://github.com/trentm/node-dashdash#readme // Definitions by: Adam Voss // Piotr Błażejewicz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export class Parser { /** Allow interspersed arguments. @default true */ interpersed: boolean; /** Don't allow unknown flags. @default true */ allowUnknown: boolean; constructor(config: ParserConfiguration); /** Return a string suitable for a Bash completion file for this tool. */ bashCompletion(args: BashCompletionConfiguration): string; /** * Return help output for the current options. * * E.g.: if the current options are: * [{names: ['help', 'h'], type: 'bool', help: 'Show help and exit.'}] * then this would return: * ' -h, --help Show help and exit.\n' */ help(config?: HelpConfiguration): string; /** Parse options from the given argv. */ parse(inputs?: string[] | ParsingConfiguration): Results; } /** * Add a new option type. */ export function addOptionType(optionType: OptionType): void; export function bashCompletionFromOptions(args: BashCompletionConfiguration): string; export function bashCompletionSpecFromOptions(args: BashCompletionSpecConfiguration): string; export function createParser(config: ParserConfiguration): Parser; export function getOptionType(name: string): OptionType; /** * Parse argv with the given options. * * @param config A merge of all the available fields from * `dashdash.Parser` and `dashdash.Parser.parse`: options, interspersed, * argv, env, slice. */ export function parse(config: ParsingConfiguration): Results; export interface Results { [key: string]: any; _order: Arg[]; _args: string[]; } export interface Arg { name: string; value: any; from: string; } /** * Return a synopsis string for the given option spec. * * Examples: * > synopsisFromOpt({names: ['help', 'h'], type: 'bool'}); * '[ --help | -h ]' * > synopsisFromOpt({name: 'file', type: 'string', helpArg: 'FILE'}); * '[ --file=FILE ]' */ export function synopsisFromOpt(o: Option): string; export type Option = OptionWithoutAliases | OptionWithAliases; export interface ParsingConfiguration { /** * The argv to parse. Defaults to `process.argv`. */ argv?: string[] | undefined; /** * The index into argv at which options/args begin. Default is 2, as appropriate for `process.argv`. */ slice?: number | undefined; /** * The env to use for 'env' entries in the option specs. Defaults to `process.env`. */ env?: any; // NodeJS.ProcessEnv; options?: Array