Initialize narratio Go module and CLI scaffold

This commit is contained in:
2026-05-02 10:37:38 -05:00
parent 48c51e1c77
commit 902e6bc994
42 changed files with 1486 additions and 1 deletions

56
internal/app/commands.go Normal file
View File

@@ -0,0 +1,56 @@
package app
import (
"context"
"fmt"
"io"
"strings"
)
var supportedCommands = []string{"run", "plan", "status", "resume", "run-stage"}
// Execute dispatches CLI commands and returns a process exit code.
func Execute(args []string, stdout, stderr io.Writer) int {
if len(args) == 0 {
printUsage(stderr)
return 1
}
ctx := context.Background()
cmd := args[0]
cmdArgs := args[1:]
var err error
switch cmd {
case "run":
err = Run(ctx, cmdArgs, stdout)
case "plan":
err = Plan(ctx, cmdArgs, stdout)
case "status":
err = Status(ctx, cmdArgs, stdout)
case "resume":
err = Resume(ctx, cmdArgs, stdout)
case "run-stage":
err = RunStage(ctx, cmdArgs, stdout)
default:
fmt.Fprintf(stderr, "unknown command: %q\n\n", cmd)
printUsage(stderr)
return 1
}
if err != nil {
fmt.Fprintf(stderr, "%v\n", err)
return 1
}
return 0
}
func printUsage(w io.Writer) {
fmt.Fprintf(w, "Usage: narratio <%s>\n", strings.Join(supportedCommands, "|"))
}
func placeholder(out io.Writer, command string) error {
_, err := fmt.Fprintf(out, "narratio %s: not yet implemented\n", command)
return err
}