@@ -286,6 +286,17 @@ function createProgressReporter(): ProgressReporter {
286286 'aliases ' => [ 'run ' ],
287287 'requiredOptions ' => [ 'site-path ' , 'site-url ' , 'mode ' ],
288288 ],
289+ 'info ' => [
290+ 'description ' => 'Show detailed information about a WordPress Blueprint ' ,
291+ 'positionalArgs ' => [
292+ 'blueprint ' => 'Path / URL / DataReference to the blueprint (required) ' ,
293+ ],
294+ 'options ' => array_merge ( $ commonOptions , [] ),
295+ 'examples ' => [
296+ 'php blueprint.php info my-blueprint.json ' ,
297+ ],
298+ 'aliases ' => [ 'explain ' , 'inspect ' ],
299+ ],
289300 'help ' => [
290301 'description ' => 'Show help for WordPress Blueprint Runner CLI ' ,
291302 'positionalArgs ' => [
@@ -372,6 +383,46 @@ function handleExecCommand( array $positionalArgs, array $options, array $comman
372383 }
373384}
374385
386+ function handleInfoCommand ( array $ positionalArgs , array $ options , array $ commandConfig , ProgressReporter $ progressReporter ): void {
387+ // Check if help is requested for this command
388+ if ( $ options ['help ' ] ) {
389+ showCommandHelpMessage ( 'info ' , $ commandConfig );
390+ exit ( 0 );
391+ }
392+
393+ // Convert CLI arguments to RunnerConfiguration
394+ $ defaults = [ 'site-path ' => '. ' , 'site-url ' => '' , 'mode ' => Runner::EXECUTION_MODE_APPLY_TO_EXISTING_SITE , 'db-engine ' => 'sqlite ' , 'truncate-new-site-directory ' => false ];
395+ $ config = cliArgsToRunnerConfiguration ( $ positionalArgs , $ options + $ defaults );
396+ $ config ->setProgressObserver ( new ProgressObserver ( function ( $ progress , $ caption ) use ( $ progressReporter ) {
397+ $ progressReporter ->reportProgress ( $ progress , $ caption );
398+ } ) );
399+ $ runner = new Runner ( $ config );
400+
401+ try {
402+ $ blueprint = $ runner ->parseBlueprint ();
403+ $ blueprint_array = $ blueprint ->getBlueprintArray ();
404+
405+ echo "BLUEPRINT: \n\n" ;
406+ foreach ( $ blueprint_array as $ key => $ value ) {
407+ echo sprintf (" %s: %s \n" , $ key , json_encode ( $ value , JSON_UNESCAPED_SLASHES ) );
408+ }
409+
410+ echo "\n" ;
411+ echo "EXECUTION PLAN: \n\n" ;
412+ foreach ( $ blueprint ->getExecutionPlan () as $ i => $ step ) {
413+ echo sprintf (" [%d] %s \n" , $ i + 1 , $ step ['name ' ]);
414+ foreach ( $ step ['args ' ] as $ key => $ value ) {
415+ echo ' ' . $ key . ': ' . json_encode ( $ value , JSON_UNESCAPED_SLASHES ) . "\n" ;
416+ }
417+ echo "\n" ;
418+ }
419+
420+ exit (0 );
421+ } catch ( InvalidArgumentException $ e ) {
422+ throw new InvalidArgumentException ( sprintf ( "Invalid Blueprint reference: %s. Hint: paths must start with ./ or /. URLs must start with http:// or https://. " , $ positionalArgs [0 ] ) );
423+ }
424+ }
425+
375426function handleHelpCommand ( array $ positionalArgs , array $ options , array $ commandConfigurations , ProgressReporter $ progressReporter ): void {
376427 if ( ! empty ( $ positionalArgs ) ) {
377428 $ requestedCommand = $ positionalArgs [0 ];
@@ -620,6 +671,9 @@ function showCommandHelpMessage( string $command, array $commandConfig ): void {
620671 case 'exec ' :
621672 handleExecCommand ( $ positionalArgs , $ options , $ commandConfigurations [ $ command ], $ progressReporter );
622673 break ;
674+ case 'info ' :
675+ handleInfoCommand ( $ positionalArgs , $ options , $ commandConfigurations [ $ command ], $ progressReporter );
676+ break ;
623677 case 'help ' :
624678 handleHelpCommand ( $ positionalArgs , $ options , $ commandConfigurations , $ progressReporter );
625679 break ;
0 commit comments