File size: 938 Bytes
b5ea024
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import type * as mri from 'mri';

type Arrayable<T> = T | T[];

declare function sade(usage: string, isSingle?: boolean): sade.Sade;

declare namespace sade {
	export type Handler = (...args: any[]) => any;
	export type Value = number | string | boolean | null;

	export interface LazyOutput {
		name: string;
		handler: Handler;
		args: string[];
	}

	export interface Sade {
		command(usage: string, description?: string, options?: {
			alias?: Arrayable<string>;
			default?: boolean;
		}): Sade;

		option(flag: string, description?: string, value?: Value): Sade;
		action(handler: Handler): Sade;
		describe(text: Arrayable<string>): Sade;
		alias(...names: string[]): Sade;
		example(usage: string): Sade;

		parse(arr: string[], opts: { lazy: true } & mri.Options): LazyOutput;
		parse(arr: string[], opts?: { lazy?: boolean } & mri.Options): void;

		version(value: string): Sade;
		help(cmd?: string): void;
	}
}

export = sade;