@@ -256,7 +256,7 @@ function createProgressReporter(): ProgressReporter {
256256 'site-url ' => [ 'u ' , true , null , 'Public site URL (https://example.com) ' ],
257257 'site-path ' => [ null , true , null , 'Target directory with WordPress install context) ' ],
258258 'execution-context ' => [ 'x ' , true , null , 'Source directory with Blueprint context files ' ],
259- 'mode ' => [ 'm ' , true , ' create-new-site ' , 'Execution mode (create-new-site|apply-to-existing-site) ' ],
259+ 'mode ' => [ 'm ' , true , Runner:: EXECUTION_MODE_CREATE_NEW_SITE , sprintf ( 'Execution mode (%s|%s) ' , Runner:: EXECUTION_MODE_CREATE_NEW_SITE , Runner:: EXECUTION_MODE_APPLY_TO_EXISTING_SITE ) ],
260260 'db-engine ' => [ 'd ' , true , 'mysql ' , 'Database engine (mysql|sqlite) ' ],
261261 'db-host ' => [ null , true , '127.0.0.1 ' , 'MySQL host ' ],
262262 'db-user ' => [ null , true , 'root ' , 'MySQL user ' ],
@@ -280,7 +280,7 @@ function createProgressReporter(): ProgressReporter {
280280 ] ),
281281 'examples ' => [
282282 'php blueprint.php exec my-blueprint.json --site-url https://mysite.test --site-path /var/www/mysite.com ' ,
283- 'php blueprint.php exec my-blueprint.json --execution-context /var/www --site-url https://mysite.test --mode apply-to-existing-site --site-path ./site ' ,
283+ sprintf ( 'php blueprint.php exec my-blueprint.json --execution-context /var/www --site-url https://mysite.test --mode %s --site-path ./site ' , Runner:: EXECUTION_MODE_APPLY_TO_EXISTING_SITE ) ,
284284 'php blueprint.php exec my-blueprint.json --site-url https://mysite.test --site-path ./mysite --truncate-new-site-directory ' ,
285285 ],
286286 'aliases ' => [ 'run ' ],
@@ -350,7 +350,7 @@ function handleExecCommand( array $positionalArgs, array $options, array $comman
350350 $ runner = new Runner ( $ config );
351351
352352 // Execute the Blueprint
353- if ( $ config ->getExecutionMode () === ' create-new-site ' ) {
353+ if ( $ config ->getExecutionMode () === Runner:: EXECUTION_MODE_CREATE_NEW_SITE ) {
354354 $ progressReporter ->reportProgress (0 , 'Creating a new site ' );
355355 } else {
356356 $ progressReporter ->reportProgress (0 , 'Updating an existing site ' );
@@ -405,24 +405,23 @@ function cliArgsToRunnerConfiguration( array $positionalArgs, array $options ):
405405 }
406406
407407 if ( ! empty ( $ options ['mode ' ] ) ) {
408- // Accept 'create-new-site' or 'apply-to-existing-site' as CLI values, map to internal values
409408 $ mode = $ options ['mode ' ];
410- if ( $ mode === ' create-new-site ' ) {
411- $ config ->setExecutionMode ( ' create-new-site ' );
412- } elseif ( $ mode === ' apply-to-existing-site ' ) {
413- $ config ->setExecutionMode ( ' apply-to-existing-site ' );
409+ if ( $ mode === Runner:: EXECUTION_MODE_CREATE_NEW_SITE ) {
410+ $ config ->setExecutionMode ( Runner:: EXECUTION_MODE_CREATE_NEW_SITE );
411+ } elseif ( $ mode === Runner:: EXECUTION_MODE_APPLY_TO_EXISTING_SITE ) {
412+ $ config ->setExecutionMode ( Runner:: EXECUTION_MODE_APPLY_TO_EXISTING_SITE );
414413 if (!empty ($ options ['wp ' ])) {
415- throw new InvalidArgumentException ( "The --wp option cannot be used with --mode=apply-to-existing-site . The WordPress version is whatever the existing site has. " );
414+ throw new InvalidArgumentException ( sprintf ( "The --wp option cannot be used with --mode=%s . The WordPress version is whatever the existing site has. " , Runner:: EXECUTION_MODE_APPLY_TO_EXISTING_SITE ) );
416415 }
417416 } else {
418- throw new InvalidArgumentException ( "Invalid execution mode: {$ mode }. Supported modes are: create-new-site, apply-to-existing-site " );
417+ throw new InvalidArgumentException ( sprintf ( "Invalid execution mode: ' {$ mode }' . Supported modes are: %s " , implode ( ' , ' , Runner:: EXECUTION_MODES ) ) );
419418 }
420419 }
421420
422421 $ targetSiteRoot = $ options ['site-path ' ];
423422 if ( $ options ['truncate-new-site-directory ' ] ) {
424- if ( $ options ['mode ' ] !== ' create-new-site ' ) {
425- throw new InvalidArgumentException ( "--truncate-new-site-directory can only be used with --mode=create-new-site " );
423+ if ( $ options ['mode ' ] !== Runner:: EXECUTION_MODE_CREATE_NEW_SITE ) {
424+ throw new InvalidArgumentException ( sprintf ( "--truncate-new-site-directory can only be used with --mode=%s " , Runner:: EXECUTION_MODE_CREATE_NEW_SITE ) );
426425 }
427426 $ absoluteTargetSiteRoot = realpath ( $ targetSiteRoot );
428427 if ( false === $ absoluteTargetSiteRoot ) {
0 commit comments