2026-08-29 18:19:54 +00:00
package app
import (
"context"
"fmt"
"io"
)
// RegenerateArtifacts expands the convenience command into its canonical run
// invocation. The run command remains the sole owner of parsing and execution.
func RegenerateArtifacts ( ctx context . Context , args [ ] string , out io . Writer ) error {
2026-09-04 01:21:37 +00:00
return regenerateArtifactsWithPipelineExecutor ( ctx , args , out , executePlan )
}
func regenerateArtifactsWithPipelineExecutor ( ctx context . Context , args [ ] string , out io . Writer , executor pipelineExecutor ) error {
2026-08-29 18:19:54 +00:00
if containsHelpOption ( args ) {
printRegenerateArtifactsHelp ( out )
return nil
}
expanded := make ( [ ] string , 0 , len ( args ) + 5 )
2026-08-29 20:43:44 +00:00
if len ( args ) > 0 && ! isCLIFlagToken ( args [ 0 ] ) {
2026-08-29 18:19:54 +00:00
expanded = append ( expanded , args [ 0 ] )
args = args [ 1 : ]
}
expanded = append ( expanded , "--force" , "--from" , "extract" , "--through" , "analyze" )
expanded = append ( expanded , args ... )
2026-09-04 01:21:37 +00:00
return runWithPipelineExecutor ( ctx , expanded , out , executor )
2026-08-29 18:19:54 +00:00
}
func containsHelpOption ( args [ ] string ) bool {
for _ , arg := range args {
if arg == "-h" || arg == "--help" {
return true
}
}
return false
}
func printRegenerateArtifactsHelp ( out io . Writer ) {
_ , _ = fmt . Fprintln ( out , "Usage: narratio regenerate-artifacts <session_id> [--artifacts <name[,name...]>] [common config flags]" )
_ , _ = fmt . Fprintln ( out )
_ , _ = fmt . Fprintln ( out , "Exactly equivalent to:" )
_ , _ = fmt . Fprintln ( out , " narratio run <session_id> --force --from extract --through analyze [caller options]" )
_ , _ = fmt . Fprintln ( out )
_ , _ = fmt . Fprintln ( out , "Extraction always runs; selected analysis artifacts and their required prerequisites are rebuilt. Publish and notify never run." )
}