diff --git a/lib/dashdash.d.ts b/lib/dashdash.d.ts new file mode 100644 index 0000000..ce2bc5a --- /dev/null +++ b/lib/dashdash.d.ts @@ -0,0 +1,290 @@ +// Type definitions for dashdash 1.14 +// Project: https://github.com/trentm/node-dashdash#readme + +/// + +export class Parser { + constructor(config: ParserConfiguration); + + bashCompletion(args: BashCompletionConfiguration): string; + + help(config?: HelpConfiguration): string; + + parse(inputs?: string[] | ParsingConfiguration): Results; +} + +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; + +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; +} + +/** + * Used by node-cmdln to put together a synopsis of options for a command + */ +export function synopsisFromOpt(o: Option): string; + +export type Option = OptionWithoutAliases | OptionWithAliases; + +export interface ParsingConfiguration { + /** + * The argv to parse. Defaults to `process.argv`. + */ + argv?: string[]; + + /** + * The index into argv at which options/args begin. Default is 2, as appropriate for `process.argv`. + */ + slice?: number; + + /** + * The env to use for 'env' entries in the option specs. Defaults to `process.env`. + */ + env?: NodeJS.ProcessEnv; + + options?: Array