summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/snonux/main.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/cmd/snonux/main.go b/cmd/snonux/main.go
index 5a9c9d3..58d6cb5 100644
--- a/cmd/snonux/main.go
+++ b/cmd/snonux/main.go
@@ -11,8 +11,10 @@ import (
"flag"
"fmt"
"log"
+ "math/rand"
"os"
"path/filepath"
+ "strings"
"codeberg.org/snonux/snonux/internal/config"
"codeberg.org/snonux/snonux/internal/generator"
@@ -31,15 +33,29 @@ func main() {
}
// parseFlags reads CLI flags and returns a validated Config.
+// Special theme value "random" picks a theme at random from the registry.
func parseFlags() (*config.Config, error) {
cfg := &config.Config{}
+ listThemes := flag.Bool("list-themes", false, "print all available theme names and exit")
flag.StringVar(&cfg.InputDir, "input", "./inbox", "directory containing new source files to process")
flag.StringVar(&cfg.OutputDir, "output", "~/git/snonux.foo/dist", "root directory for generated static site output")
flag.StringVar(&cfg.BaseURL, "base-url", "https://snonux.foo", "canonical base URL used in Atom feed links")
- flag.StringVar(&cfg.Theme, "theme", "neon", "visual theme: aurora, brutalist, glass, matrix, minimal, neon, ocean, paper, retro, synthwave, terminal")
+ flag.StringVar(&cfg.Theme, "theme", "neon", "visual theme name, or \"random\" to pick one at random")
flag.Parse()
+ if *listThemes {
+ fmt.Println(strings.Join(generator.ListThemes(), "\n"))
+ os.Exit(0)
+ }
+
+ // Resolve the special "random" value before any further validation.
+ if cfg.Theme == "random" {
+ themes := generator.ListThemes()
+ cfg.Theme = themes[rand.Intn(len(themes))]
+ log.Printf("random theme selected: %s", cfg.Theme)
+ }
+
var err error
cfg.InputDir, err = expandHome(cfg.InputDir)