forked from sindresorhus/meow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminimist-options.d.ts
66 lines (57 loc) · 1.91 KB
/
minimist-options.d.ts
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* eslint-disable import/no-extraneous-dependencies */
declare module 'minimist-options' {
import type {Opts as MinimistOptions} from 'minimist';
export type OptionType = 'string' | 'boolean' | 'number' | 'array' | 'string-array' | 'boolean-array' | 'number-array';
export type BaseOption<
TypeOptionType extends OptionType,
DefaultOptionType,
> = {
/**
* The data type the option should be parsed to.
*/
readonly type?: TypeOptionType;
/**
* An alias/list of aliases for the option.
*/
readonly alias?: string | readonly string[];
/**
* The default value for the option.
*/
readonly default?: DefaultOptionType;
};
export type StringOption = BaseOption<'string', string>;
export type BooleanOption = BaseOption<'boolean', boolean>;
export type NumberOption = BaseOption<'number', number>;
export type DefaultArrayOption = BaseOption<'array', readonly string[]>;
export type StringArrayOption = BaseOption<'string-array', readonly string[]>;
export type BooleanArrayOption = BaseOption<'boolean-array', readonly boolean[]>;
export type NumberArrayOption = BaseOption<'number-array', readonly number[]>;
export type AnyOption = (
| StringOption
| BooleanOption
| NumberOption
| DefaultArrayOption
| StringArrayOption
| BooleanArrayOption
| NumberArrayOption
);
export type MinimistOption = Pick<MinimistOptions, 'stopEarly' | 'unknown' | '--'>;
export type Options = MinimistOption & {
[key: string]: (
| OptionType
| StringOption
| BooleanOption
| NumberOption
| DefaultArrayOption
| StringArrayOption
| BooleanArrayOption
| NumberArrayOption
);
arguments?: string;
};
/**
* Write options for [minimist](https://npmjs.org/package/minimist) in a comfortable way. Support string, boolean, number and array options.
*/
export default function buildOptions(options?: Options): MinimistOptions;
export {type Opts as MinimistOptions} from 'minimist';
}