diff options
Diffstat (limited to 'internal/comic/runner.go')
| -rw-r--r-- | internal/comic/runner.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/internal/comic/runner.go b/internal/comic/runner.go index 5843aab..00275b8 100644 --- a/internal/comic/runner.go +++ b/internal/comic/runner.go @@ -128,7 +128,7 @@ func (r *Runner) Run(ctx context.Context, batchFile string) error { fmt.Printf(" Comic title: %q (slug: %s)\n", result.Title, slug) } - comicsDir := filepath.Join(dir, "comics", slug) + comicsDir := comicOutputDir(dir, slug) if err := os.MkdirAll(comicsDir, 0o755); err != nil { return fmt.Errorf("create comics dir %s: %w", comicsDir, err) } @@ -171,6 +171,14 @@ func (r *Runner) Run(ctx context.Context, batchFile string) error { return r.handleNarration(ctx, result.StoryText, slug, comicsDir) } +func comicOutputDir(outputRoot, slug string) string { + root := orDefault(outputRoot, ".") + if filepath.Base(filepath.Clean(root)) == "comics" { + return filepath.Join(root, slug) + } + return filepath.Join(root, "comics", slug) +} + var _ StoryRunner = (*Runner)(nil) func (r *Runner) handleNarration(ctx context.Context, storyText, titleSlug, dir string) error { |
