-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflag-types.ts
More file actions
128 lines (125 loc) · 2.72 KB
/
flag-types.ts
File metadata and controls
128 lines (125 loc) · 2.72 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/**
* @fileoverview Types + `COMMON_FLAGS` table for argv flag parsing.
*
* Split out of `argv/flags.ts` for size hygiene. Pure values + types
* only; no I/O or runtime side effects so this module stays cheap to
* import everywhere.
*/
/**
* Flag values object from parsed arguments.
*/
export interface FlagValues {
[key: string]: unknown
quiet?: boolean
silent?: boolean
verbose?: boolean
help?: boolean
all?: boolean
fix?: boolean
force?: boolean
'dry-run'?: boolean
json?: boolean
debug?: boolean
watch?: boolean
coverage?: boolean
cover?: boolean
update?: boolean
staged?: boolean
changed?: boolean
}
/**
* Accepted input types for flag checking functions.
* Can be parsed flag values, process.argv array, or undefined (uses process.argv).
*/
export type FlagInput = FlagValues | string[] | readonly string[] | undefined
/**
* Common flag definitions for parseArgs configuration.
* Can be spread into parseArgs options for consistency.
*/
export const COMMON_FLAGS = {
all: {
type: 'boolean' as const,
default: false,
description: 'Target all files',
},
changed: {
type: 'boolean' as const,
default: false,
description: 'Target changed files',
},
coverage: {
type: 'boolean' as const,
default: false,
description: 'Run with coverage',
},
cover: {
type: 'boolean' as const,
default: false,
description: 'Run with coverage (alias)',
},
debug: {
type: 'boolean' as const,
default: false,
description: 'Enable debug output',
},
'dry-run': {
type: 'boolean' as const,
default: false,
description: 'Perform a dry run',
},
fix: {
type: 'boolean' as const,
default: false,
description: 'Automatically fix issues',
},
force: {
type: 'boolean' as const,
default: false,
description: 'Force the operation',
},
help: {
type: 'boolean' as const,
default: false,
short: 'h',
description: 'Show help',
},
json: {
type: 'boolean' as const,
default: false,
description: 'Output as JSON',
},
quiet: {
type: 'boolean' as const,
default: false,
short: 'q',
description: 'Suppress output',
},
silent: {
type: 'boolean' as const,
default: false,
description: 'Suppress all output',
},
staged: {
type: 'boolean' as const,
default: false,
description: 'Target staged files',
},
update: {
type: 'boolean' as const,
default: false,
short: 'u',
description: 'Update snapshots/deps',
},
verbose: {
type: 'boolean' as const,
default: false,
short: 'v',
description: 'Verbose output',
},
watch: {
type: 'boolean' as const,
default: false,
short: 'w',
description: 'Watch mode',
},
}