summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-21 23:12:52 +0300
committerPaul Buetow <paul@buetow.org>2026-04-21 23:12:52 +0300
commit3e99f5a75e14455aa75ca3a1dc7d08bd3e6f55fd (patch)
tree568bb781c0d71bdea58f5dc7192e6c5edec94c27 /cmd
parentd15846a2784d15c5043833874b6539b727555cb0 (diff)
u7: wire documented config knobs into runtime
Diffstat (limited to 'cmd')
-rw-r--r--cmd/comicforge/cli.go9
-rw-r--r--cmd/comicforge/cli_test.go46
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) {