package cli import ( "bytes" "context" "os" "path/filepath" "strings" "testing" "time" "gitea.maximumdirect.net/eric/weatherreporter/internal/promptexec" "gitea.maximumdirect.net/eric/weatherreporter/internal/timeutil" ) func TestParseRunFlagsAcceptsPromptDebugDirectory(t *testing.T) { opts, err := parseRunFlags([]string{"--llm-debug-dir", "/tmp/prompt-debug"}) if err != nil || opts.LLMDebugDir != "/tmp/prompt-debug" { t.Fatalf("parseRunFlags() = %#v, %v", opts, err) } } func TestResolveRunActionConstructsOneExecutor(t *testing.T) { for _, command := range []string{"morning", "evening"} { t.Run(command, func(t *testing.T) { configPath := filepath.Join(t.TempDir(), "config.yml") if err := os.WriteFile(configPath, []byte("workspace:\n root: "+filepath.Join(t.TempDir(), "workspace")+"\n"), 0o600); err != nil { t.Fatal(err) } calls := 0 executor := &factoryExecutor{} runner := Runner{ Clock: timeutil.FixedClock{Time: time.Date(2026, 5, 29, 8, 0, 0, 0, time.UTC)}, ExecutorFactory: func(PromptExecutorConfig) (promptexec.Executor, error) { calls++ return executor, nil }, } req, _, err := runner.resolveRunAction([]string{command, "--config", configPath, "--llm-debug-dir", "/tmp/debug"}) if err != nil || calls != 1 || req.Executor != executor || req.LLMDebugDir != "/tmp/debug" { t.Fatalf("resolveRunAction() request/error/calls = %#v/%v/%d", req, err, calls) } }) } } func TestInspectCommandIsUnknownAndAbsentFromHelp(t *testing.T) { var stdout, stderr bytes.Buffer err := (Runner{}).Run(context.Background(), []string{"inspect", "reports"}, &stdout, &stderr) if err == nil || err.Error() != `unknown command "inspect"` { t.Fatalf("Run(inspect) error = %v", err) } if err := (Runner{}).Run(context.Background(), []string{"--help"}, &stdout, &stderr); err != nil { t.Fatalf("Run(--help) error = %v", err) } if strings.Contains(stdout.String(), "inspect") { t.Fatalf("help contains removed inspect command:\n%s", stdout.String()) } }