package app import ( "context" "flag" "fmt" "io" "gitea.maximumdirect.net/eric/narratio/internal/config" ) // Run executes the placeholder stage pipeline and persists manifest state. func Run(ctx context.Context, args []string, out io.Writer) error { fs := flag.NewFlagSet("run", flag.ContinueOnError) fs.SetOutput(io.Discard) var pipelinePath string var sessionPath string var force bool fs.StringVar(&pipelinePath, "config", "", "path to pipeline.yml") fs.StringVar(&sessionPath, "session", "", "path to session.yml") fs.BoolVar(&force, "force", false, "force stage execution (reserved for future behavior)") if err := fs.Parse(args); err != nil { return fmt.Errorf("run: invalid flags: %w", err) } if fs.NArg() != 0 { return fmt.Errorf("run: unexpected positional arguments") } if pipelinePath == "" || sessionPath == "" { return fmt.Errorf("run: --config and --session are required") } cfg, err := config.Load(pipelinePath, sessionPath) if err != nil { return fmt.Errorf("run: %w", err) } if err := config.Validate(cfg); err != nil { return fmt.Errorf("run: %w", err) } stages := BuildFullPlan() summary, err := executeStages(ctx, cfg, stages, RunOptions{Force: force}) if err != nil { return fmt.Errorf("run: %w", err) } _, err = fmt.Fprintf(out, "narratio run: completed %d placeholder stages for session %s; manifest updated at %s\n", len(summary.StageNames), summary.SessionID, summary.ManifestPath) return err }