@@ -15,6 +15,7 @@ import {
1515 resolveCommand , buildArgs , runCommand , extractPositionalMappings ,
1616 extractEnvVars , killCurrentChildProcess , hasInteractiveMarker ,
1717} from "./command" ;
18+ import { startSpinner } from "./spinner" ;
1819import { getProcessManager } from "./process-manager" ;
1920import {
2021 expandImports , hasImports ,
@@ -323,6 +324,10 @@ export class CliRunner {
323324
324325 getCommandLogger ( ) . info ( { command, argsCount : finalRunArgs . length , promptLength : finalBody . length } , "Executing command" ) ;
325326
327+ // Start spinner with command preview (will be stopped when first output arrives)
328+ const preview = formatCommandPreview ( command , finalRunArgs ) ;
329+ startSpinner ( preview ) ;
330+
326331 const runResult = await runCommand ( {
327332 command, args : finalRunArgs , positionals : [ finalBody ] , positionalMappings, captureOutput : false , env : extractEnvVars ( frontmatter ) ,
328333 } ) ;
@@ -628,6 +633,53 @@ export class CliRunner {
628633 }
629634}
630635
636+ /**
637+ * Format a command preview for the spinner message
638+ * Shows command + subcommands + key flags in a concise format
639+ */
640+ function formatCommandPreview ( command : string , args : string [ ] , maxLength = 60 ) : string {
641+ // Build a representation: command subcommand flag1 flag2 ...
642+ const parts = [ command ] ;
643+
644+ // First, add any leading non-flag args (subcommands like "exec")
645+ let i = 0 ;
646+ while ( i < args . length ) {
647+ const arg = args [ i ] ;
648+ if ( ! arg || arg . startsWith ( "-" ) ) break ;
649+ // Include subcommands (short non-flag args)
650+ if ( arg . length <= 20 ) {
651+ parts . push ( arg ) ;
652+ }
653+ i ++ ;
654+ }
655+
656+ // Then add flags and their short values
657+ for ( ; i < args . length ; i ++ ) {
658+ const arg = args [ i ] ;
659+ if ( ! arg ) continue ;
660+
661+ if ( arg . startsWith ( "-" ) ) {
662+ // It's a flag - add it
663+ parts . push ( arg ) ;
664+ // Check if next arg is a short value (not another flag)
665+ const nextArg = args [ i + 1 ] ;
666+ if ( nextArg && ! nextArg . startsWith ( "-" ) && nextArg . length <= 20 ) {
667+ parts . push ( nextArg ) ;
668+ i ++ ;
669+ }
670+ }
671+ }
672+
673+ let preview = parts . join ( " " ) ;
674+
675+ // Truncate if too long
676+ if ( preview . length > maxLength ) {
677+ preview = preview . slice ( 0 , maxLength - 3 ) + "..." ;
678+ }
679+
680+ return preview ;
681+ }
682+
631683/** Create a CliRunner with the given environment */
632684export function createCliRunner ( env : SystemEnvironment , options ?: Partial < Omit < CliRunnerOptions , "env" > > ) : CliRunner {
633685 return new CliRunner ( { env, ...options } ) ;
0 commit comments