@@ -4,6 +4,33 @@ const Codecept = require('../lib/codecept');
44const { print, error } = require ( '../lib/output' ) ;
55const { printError } = require ( '../lib/command/utils' ) ;
66
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+
734const errorHandler = ( fn ) => async ( ...args ) => {
835 try {
936 await fn ( ...args ) ;
@@ -35,9 +62,10 @@ program.command('migrate [path]')
3562program . command ( 'shell [path]' )
3663 . alias ( 'sh' )
3764 . 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 )
4169 . action ( errorHandler ( require ( '../lib/command/interactive' ) ) ) ;
4270
4371program . command ( 'list [path]' )
@@ -47,27 +75,27 @@ program.command('list [path]')
4775
4876program . command ( 'def [path]' )
4977 . 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 )
5179 . option ( '-o, --output [folder]' , 'target folder to paste definitions' )
5280 . action ( errorHandler ( require ( '../lib/command/definitions' ) ) ) ;
5381
5482program . command ( 'gherkin:init [path]' )
5583 . alias ( 'bdd:init' )
5684 . 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 )
5886 . action ( errorHandler ( require ( '../lib/command/gherkin/init' ) ) ) ;
5987
6088program . command ( 'gherkin:steps [path]' )
6189 . alias ( 'bdd:steps' )
6290 . description ( 'Prints all defined gherkin steps.' )
63- . option ( '-c, -- config [file]' , 'configuration file to be used' )
91+ . option ( commandFlags . config . flag , commandFlags . config . description )
6492 . action ( errorHandler ( require ( '../lib/command/gherkin/steps' ) ) ) ;
6593
6694program . command ( 'gherkin:snippets [path]' )
6795 . alias ( 'bdd:snippets' )
6896 . description ( 'Generate step definitions from steps.' )
6997 . 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 )
7199 . option ( '--feature [file]' , 'feature files(s) to scan' )
72100 . option ( '--path [file]' , 'file in which to place the new snippets' )
73101 . action ( errorHandler ( require ( '../lib/command/gherkin/snippets' ) ) ) ;
@@ -93,16 +121,22 @@ program.command('generate:helper [path]')
93121 . description ( 'Generates a new helper' )
94122 . action ( errorHandler ( require ( '../lib/command/generate' ) . helper ) ) ;
95123
124+ program . command ( 'generate:heal [path]' )
125+ . alias ( 'gr' )
126+ . description ( 'Generates basic heal recipes' )
127+ . action ( errorHandler ( require ( '../lib/command/generate' ) . heal ) ) ;
128+
96129program . command ( 'run [test]' )
97130 . description ( 'Executes tests' )
98131
99132 // 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 )
103137 . 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 )
106140 . option ( '--features' , 'run only *.feature files and skip tests' )
107141 . option ( '--tests' , 'run only JS test files and skip features' )
108142 . option ( '--no-timeouts' , 'disable all timeouts' )
@@ -132,34 +166,36 @@ program.command('run [test]')
132166
133167program . command ( 'run-workers <workers> [selectedRuns...]' )
134168 . description ( 'Executes tests in workers' )
135- . option ( '-c, -- config [file]' , 'configuration file to be used' )
169+ . option ( commandFlags . config . flag , commandFlags . config . description )
136170 . option ( '-g, --grep <pattern>' , 'only run tests matching <pattern>' )
137171 . option ( '-i, --invert' , 'inverts --grep matches' )
138172 . option ( '-o, --override [value]' , 'override current config options' )
139173 . 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 )
142176 . option ( '--features' , 'run only *.feature files and skip tests' )
143177 . 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 )
145180 . option ( '-p, --plugins <k=v,k2=v2,...>' , 'enable plugins, comma-separated' )
146181 . option ( '-O, --reporter-options <k=v,k2=v2,...>' , 'reporter-specific options' )
147182 . option ( '-R, --reporter <name>' , 'specify the reporter to use' )
148183 . action ( errorHandler ( require ( '../lib/command/run-workers' ) ) ) ;
149184
150185program . command ( 'run-multiple [suites...]' )
151186 . 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 )
154189 . option ( '--all' , 'run all suites' )
155190 . option ( '--features' , 'run only *.feature files and skip tests' )
156191 . option ( '--tests' , 'run only JS test files and skip features' )
192+ . option ( commandFlags . ai . flag , commandFlags . ai . description )
157193 . option ( '-g, --grep <pattern>' , 'only run tests matching <pattern>' )
158194 . option ( '-f, --fgrep <string>' , 'only run tests containing <string>' )
159195 . 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 )
163199 . option ( '-p, --plugins <k=v,k2=v2,...>' , 'enable plugins, comma-separated' )
164200 . option ( '-o, --override [value]' , 'override current config options' )
165201 . option ( '-O, --reporter-options <k=v,k2=v2,...>' , 'reporter-specific options' )
@@ -180,28 +216,28 @@ program.command('dry-run [test]')
180216 . description ( 'Prints step-by-step scenario for a test without actually running it' )
181217 . option ( '-p, --plugins <k=v,k2=v2,...>' , 'enable plugins, comma-separated' )
182218 . 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 )
184220 . option ( '--all' , 'run all suites' )
185221 . option ( '--features' , 'run only *.feature files and skip tests' )
186222 . option ( '--tests' , 'run only JS test files and skip features' )
187223 . option ( '-g, --grep <pattern>' , 'only run tests matching <pattern>' )
188224 . option ( '-f, --fgrep <string>' , 'only run tests containing <string>' )
189225 . 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 )
193229 . action ( errorHandler ( require ( '../lib/command/dryRun' ) ) ) ;
194230
195231program . command ( 'run-rerun [test]' )
196232 . description ( 'Executes tests in more than one test suite run' )
197233
198234 // 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 )
202238 . 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 )
205241 . option ( '--features' , 'run only *.feature files and skip tests' )
206242 . option ( '--tests' , 'run only JS test files and skip features' )
207243 . option ( '-p, --plugins <k=v,k2=v2,...>' , 'enable plugins, comma-separated' )
0 commit comments