diff options
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/comicforge/cli.go | 9 | ||||
| -rw-r--r-- | cmd/comicforge/cli_test.go | 46 |
2 files changed, 55 insertions, 0 deletions
diff --git a/cmd/comicforge/cli.go b/cmd/comicforge/cli.go index e472108..a87a226 100644 --- a/cmd/comicforge/cli.go +++ b/cmd/comicforge/cli.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "strings" + "time" "github.com/spf13/cobra" @@ -151,6 +152,8 @@ func runCommand(ctx context.Context, cmd *cobra.Command, deps commandDeps, flags Prompts: cfg, OutputDir: flags.outputDir, Style: flags.style, + ComicStyles: cfg.Styles.Comic, + RealisticStyles: cfg.Styles.Realistic, Theme: flags.theme, Language: cfg.Language.Story, Script: cfg.Language.Script, @@ -158,6 +161,12 @@ func runCommand(ctx context.Context, cmd *cobra.Command, deps commandDeps, flags Slug: flags.slug, NarrateEnabled: flags.narrateEnabled, UltraRealistic: resolveUltraRealistic(flags), + RealisticWeight: cfg.Story.RealisticWeight, + AspectRatio: cfg.Comic.AspectRatio, + PromptMaxChars: cfg.Comic.PromptMaxChars, + PageMaxRetries: cfg.Comic.PageMaxRetries, + PageRetryBase: time.Duration(cfg.Comic.PageRetryBaseSeconds) * time.Second, + ChunkWords: cfg.Narration.ChunkWords, StoryPages: cfg.Comic.StoryPages, GalleryPages: cfg.Comic.GalleryPages, PanelsPerPage: cfg.Comic.PanelsPerPage, diff --git a/cmd/comicforge/cli_test.go b/cmd/comicforge/cli_test.go index 4cf49f8..fd7904c 100644 --- a/cmd/comicforge/cli_test.go +++ b/cmd/comicforge/cli_test.go @@ -184,6 +184,52 @@ prompts_dir: ./config-prompts } } +func TestRootCommandUsesRealisticWeightWhenUltraModeUnset(t *testing.T) { + tmpDir := t.TempDir() + configPath := filepath.Join(tmpDir, "config.yaml") + if err := os.WriteFile(configPath, []byte(strings.TrimSpace(` +story: + realistic_weight: 0 +`)), 0o644); err != nil { + t.Fatalf("write config: %v", err) + } + + var gotRunnerCfg *comic.RunnerConfig + cmd := newRootCommandWithDeps(commandDeps{ + loadConfig: func(path string) (*config.Config, error) { + return config.Load(path) + }, + newTextProvider: func(*config.Config) (provider.TextProvider, error) { return noopProvider{}, nil }, + newImageProvider: func(*config.Config) (provider.ImageProvider, error) { return noopProvider{}, nil }, + newTTSProvider: func(*config.Config, string) (provider.TTSProvider, error) { return noopProvider{}, nil }, + newRunner: func(cfg *comic.RunnerConfig) comic.StoryRunner { + gotRunnerCfg = cfg + return &recordingRunner{} + }, + }) + buf := &bytes.Buffer{} + cmd.SetOut(buf) + cmd.SetErr(buf) + vocabPath := filepath.Join(tmpDir, "vocab.txt") + if err := os.WriteFile(vocabPath, []byte("ябълка = apple\n"), 0o644); err != nil { + t.Fatalf("write vocab: %v", err) + } + cmd.SetArgs([]string{"--config", configPath, "--vocab", vocabPath}) + + if err := cmd.ExecuteContext(context.Background()); err != nil { + t.Fatalf("ExecuteContext() error = %v\noutput:\n%s", err, buf.String()) + } + if gotRunnerCfg == nil { + t.Fatal("runner config was not captured") + } + if got, want := gotRunnerCfg.RealisticWeight, 0.0; got != want { + t.Fatalf("realistic weight = %v, want %v", got, want) + } + if gotRunnerCfg.UltraRealistic != nil { + t.Fatalf("ultra realistic override = %#v, want nil when flags are unset", gotRunnerCfg.UltraRealistic) + } +} + func TestRootCommandVersionSkipsRequiredFlags(t *testing.T) { cmd := newRootCommandWithDeps(commandDeps{ loadConfig: func(string) (*config.Config, error) { |
