@@ -4,6 +4,33 @@ const Codecept = require('../lib/codecept');
4
4
const { print, error } = require ( '../lib/output' ) ;
5
5
const { printError } = require ( '../lib/command/utils' ) ;
6
6
7
+ const commandFlags = {
8
+ ai : {
9
+ flag : '--ai' ,
10
+ description : 'enable AI assistant' ,
11
+ } ,
12
+ verbose : {
13
+ flag : '--verbose' ,
14
+ description : 'output internal logging information' ,
15
+ } ,
16
+ debug : {
17
+ flag : '--debug' ,
18
+ description : 'output additional information' ,
19
+ } ,
20
+ config : {
21
+ flag : '-c, --config [file]' ,
22
+ description : 'configuration file to be used' ,
23
+ } ,
24
+ profile : {
25
+ flag : '--profile [value]' ,
26
+ description : 'configuration profile to be used' ,
27
+ } ,
28
+ steps : {
29
+ flag : '--steps' ,
30
+ description : 'show step-by-step execution' ,
31
+ } ,
32
+ } ;
33
+
7
34
const errorHandler = ( fn ) => async ( ...args ) => {
8
35
try {
9
36
await fn ( ...args ) ;
@@ -35,9 +62,10 @@ program.command('migrate [path]')
35
62
program . command ( 'shell [path]' )
36
63
. alias ( 'sh' )
37
64
. description ( 'Interactive shell' )
38
- . option ( '--verbose' , 'output internal logging information' )
39
- . option ( '--profile [value]' , 'configuration profile to be used' )
40
- . option ( '-c, --config [file]' , 'configuration file to be used' )
65
+ . option ( commandFlags . verbose . flag , commandFlags . verbose . description )
66
+ . option ( commandFlags . profile . flag , commandFlags . profile . description )
67
+ . option ( commandFlags . ai . flag , commandFlags . ai . description )
68
+ . option ( commandFlags . config . flag , commandFlags . config . description )
41
69
. action ( errorHandler ( require ( '../lib/command/interactive' ) ) ) ;
42
70
43
71
program . command ( 'list [path]' )
@@ -47,27 +75,27 @@ program.command('list [path]')
47
75
48
76
program . command ( 'def [path]' )
49
77
. description ( 'Generates TypeScript definitions for all I actions.' )
50
- . option ( '-c, -- config [file]' , 'configuration file to be used' )
78
+ . option ( commandFlags . config . flag , commandFlags . config . description )
51
79
. option ( '-o, --output [folder]' , 'target folder to paste definitions' )
52
80
. action ( errorHandler ( require ( '../lib/command/definitions' ) ) ) ;
53
81
54
82
program . command ( 'gherkin:init [path]' )
55
83
. alias ( 'bdd:init' )
56
84
. description ( 'Prepare CodeceptJS to run feature files.' )
57
- . option ( '-c, -- config [file]' , 'configuration file to be used' )
85
+ . option ( commandFlags . config . flag , commandFlags . config . description )
58
86
. action ( errorHandler ( require ( '../lib/command/gherkin/init' ) ) ) ;
59
87
60
88
program . command ( 'gherkin:steps [path]' )
61
89
. alias ( 'bdd:steps' )
62
90
. description ( 'Prints all defined gherkin steps.' )
63
- . option ( '-c, -- config [file]' , 'configuration file to be used' )
91
+ . option ( commandFlags . config . flag , commandFlags . config . description )
64
92
. action ( errorHandler ( require ( '../lib/command/gherkin/steps' ) ) ) ;
65
93
66
94
program . command ( 'gherkin:snippets [path]' )
67
95
. alias ( 'bdd:snippets' )
68
96
. description ( 'Generate step definitions from steps.' )
69
97
. option ( '--dry-run' , "don't save snippets to file" )
70
- . option ( '-c, -- config [file]' , 'configuration file to be used' )
98
+ . option ( commandFlags . config . flag , commandFlags . config . description )
71
99
. option ( '--feature [file]' , 'feature files(s) to scan' )
72
100
. option ( '--path [file]' , 'file in which to place the new snippets' )
73
101
. action ( errorHandler ( require ( '../lib/command/gherkin/snippets' ) ) ) ;
@@ -93,16 +121,22 @@ program.command('generate:helper [path]')
93
121
. description ( 'Generates a new helper' )
94
122
. action ( errorHandler ( require ( '../lib/command/generate' ) . helper ) ) ;
95
123
124
+ program . command ( 'generate:heal [path]' )
125
+ . alias ( 'gr' )
126
+ . description ( 'Generates basic heal recipes' )
127
+ . action ( errorHandler ( require ( '../lib/command/generate' ) . heal ) ) ;
128
+
96
129
program . command ( 'run [test]' )
97
130
. description ( 'Executes tests' )
98
131
99
132
// codecept-only options
100
- . option ( '--steps' , 'show step-by-step execution' )
101
- . option ( '--debug' , 'output additional information' )
102
- . option ( '--verbose' , 'output internal logging information' )
133
+ . option ( commandFlags . ai . flag , commandFlags . ai . description )
134
+ . option ( commandFlags . steps . flag , commandFlags . steps . description )
135
+ . option ( commandFlags . debug . flag , commandFlags . debug . description )
136
+ . option ( commandFlags . verbose . flag , commandFlags . verbose . description )
103
137
. option ( '-o, --override [value]' , 'override current config options' )
104
- . option ( '-- profile [value]' , 'configuration profile to be used' )
105
- . option ( '-c, -- config [file]' , 'configuration file to be used' )
138
+ . option ( commandFlags . profile . flag , commandFlags . profile . description )
139
+ . option ( commandFlags . config . flag , commandFlags . config . description )
106
140
. option ( '--features' , 'run only *.feature files and skip tests' )
107
141
. option ( '--tests' , 'run only JS test files and skip features' )
108
142
. option ( '--no-timeouts' , 'disable all timeouts' )
@@ -132,34 +166,36 @@ program.command('run [test]')
132
166
133
167
program . command ( 'run-workers <workers> [selectedRuns...]' )
134
168
. description ( 'Executes tests in workers' )
135
- . option ( '-c, -- config [file]' , 'configuration file to be used' )
169
+ . option ( commandFlags . config . flag , commandFlags . config . description )
136
170
. option ( '-g, --grep <pattern>' , 'only run tests matching <pattern>' )
137
171
. option ( '-i, --invert' , 'inverts --grep matches' )
138
172
. option ( '-o, --override [value]' , 'override current config options' )
139
173
. option ( '--suites' , 'parallel execution of suites not single tests' )
140
- . option ( '-- debug' , 'output additional information' )
141
- . option ( '-- verbose' , 'output internal logging information' )
174
+ . option ( commandFlags . debug . flag , commandFlags . debug . description )
175
+ . option ( commandFlags . verbose . flag , commandFlags . verbose . description )
142
176
. option ( '--features' , 'run only *.feature files and skip tests' )
143
177
. option ( '--tests' , 'run only JS test files and skip features' )
144
- . option ( '--profile [value]' , 'configuration profile to be used' )
178
+ . option ( commandFlags . profile . flag , commandFlags . profile . description )
179
+ . option ( commandFlags . ai . flag , commandFlags . ai . description )
145
180
. option ( '-p, --plugins <k=v,k2=v2,...>' , 'enable plugins, comma-separated' )
146
181
. option ( '-O, --reporter-options <k=v,k2=v2,...>' , 'reporter-specific options' )
147
182
. option ( '-R, --reporter <name>' , 'specify the reporter to use' )
148
183
. action ( errorHandler ( require ( '../lib/command/run-workers' ) ) ) ;
149
184
150
185
program . command ( 'run-multiple [suites...]' )
151
186
. description ( 'Executes tests multiple' )
152
- . option ( '-c, -- config [file]' , 'configuration file to be used' )
153
- . option ( '-- profile [value]' , 'configuration profile to be used' )
187
+ . option ( commandFlags . config . flag , commandFlags . config . description )
188
+ . option ( commandFlags . profile . flag , commandFlags . profile . description )
154
189
. option ( '--all' , 'run all suites' )
155
190
. option ( '--features' , 'run only *.feature files and skip tests' )
156
191
. option ( '--tests' , 'run only JS test files and skip features' )
192
+ . option ( commandFlags . ai . flag , commandFlags . ai . description )
157
193
. option ( '-g, --grep <pattern>' , 'only run tests matching <pattern>' )
158
194
. option ( '-f, --fgrep <string>' , 'only run tests containing <string>' )
159
195
. option ( '-i, --invert' , 'inverts --grep and --fgrep matches' )
160
- . option ( '-- steps' , 'show step-by-step execution' )
161
- . option ( '-- verbose' , 'output internal logging information' )
162
- . option ( '-- debug' , 'output additional information' )
196
+ . option ( commandFlags . steps . flag , commandFlags . steps . description )
197
+ . option ( commandFlags . verbose . flag , commandFlags . verbose . description )
198
+ . option ( commandFlags . debug . flag , commandFlags . debug . description )
163
199
. option ( '-p, --plugins <k=v,k2=v2,...>' , 'enable plugins, comma-separated' )
164
200
. option ( '-o, --override [value]' , 'override current config options' )
165
201
. option ( '-O, --reporter-options <k=v,k2=v2,...>' , 'reporter-specific options' )
@@ -180,28 +216,28 @@ program.command('dry-run [test]')
180
216
. description ( 'Prints step-by-step scenario for a test without actually running it' )
181
217
. option ( '-p, --plugins <k=v,k2=v2,...>' , 'enable plugins, comma-separated' )
182
218
. option ( '--bootstrap' , 'enable bootstrap & teardown scripts for dry-run' )
183
- . option ( '-c, -- config [file]' , 'configuration file to be used' )
219
+ . option ( commandFlags . config . flag , commandFlags . config . description )
184
220
. option ( '--all' , 'run all suites' )
185
221
. option ( '--features' , 'run only *.feature files and skip tests' )
186
222
. option ( '--tests' , 'run only JS test files and skip features' )
187
223
. option ( '-g, --grep <pattern>' , 'only run tests matching <pattern>' )
188
224
. option ( '-f, --fgrep <string>' , 'only run tests containing <string>' )
189
225
. option ( '-i, --invert' , 'inverts --grep and --fgrep matches' )
190
- . option ( '-- steps' , 'show step-by-step execution' )
191
- . option ( '-- verbose' , 'output internal logging information' )
192
- . option ( '-- debug' , 'output additional information' )
226
+ . option ( commandFlags . steps . flag , commandFlags . steps . description )
227
+ . option ( commandFlags . verbose . flag , commandFlags . verbose . description )
228
+ . option ( commandFlags . debug . flag , commandFlags . debug . description )
193
229
. action ( errorHandler ( require ( '../lib/command/dryRun' ) ) ) ;
194
230
195
231
program . command ( 'run-rerun [test]' )
196
232
. description ( 'Executes tests in more than one test suite run' )
197
233
198
234
// codecept-only options
199
- . option ( '-- steps' , 'show step-by-step execution' )
200
- . option ( '-- debug' , 'output additional information' )
201
- . option ( '-- verbose' , 'output internal logging information' )
235
+ . option ( commandFlags . steps . flag , commandFlags . steps . description )
236
+ . option ( commandFlags . debug . flag , commandFlags . debug . description )
237
+ . option ( commandFlags . verbose . flag , commandFlags . verbose . description )
202
238
. option ( '-o, --override [value]' , 'override current config options' )
203
- . option ( '-- profile [value]' , 'configuration profile to be used' )
204
- . option ( '-c, -- config [file]' , 'configuration file to be used' )
239
+ . option ( commandFlags . profile . flag , commandFlags . profile . description )
240
+ . option ( commandFlags . config . flag , commandFlags . config . description )
205
241
. option ( '--features' , 'run only *.feature files and skip tests' )
206
242
. option ( '--tests' , 'run only JS test files and skip features' )
207
243
. option ( '-p, --plugins <k=v,k2=v2,...>' , 'enable plugins, comma-separated' )
0 commit comments