Files
narratio/internal/app/regenerate_artifacts.go

44 lines
1.3 KiB
Go

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 {
if containsHelpOption(args) {
printRegenerateArtifactsHelp(out)
return nil
}
expanded := make([]string, 0, len(args)+5)
if len(args) > 0 {
expanded = append(expanded, args[0])
args = args[1:]
}
expanded = append(expanded, "--force", "--from", "extract", "--through", "analyze")
expanded = append(expanded, args...)
return runCommandFn(ctx, expanded, out)
}
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.")
}