Files
GiteaMailTemplates/tools/tools.go
T
KenanZhuandClaude Opus 4.8 0bf982ffb9 refactor(tools): modularize CLI with urfave/cli/v2, externalise template metadata
- Split monolithic build-preview.go into modular packages:
  tools.go (entry), cli/ (list/create/delete/preview commands),
  config/ (JSON loading), preview/ (rendering engine, funcs, locale)
- Extract all template metadata into data/templates_config.json
  as single source of truth — no hardcoded template data in Go
- Replace hand-rolled CLI parsing with github.com/urfave/cli/v2
- Add sensible defaults for --folder (../themes) and --config
  (./data/templates_config.json) — most commands now run bare
- Add type-coercing gt/lt/ge/le template funcs for JSON float64
- Fix AppUrl to gitea.com matching official template convention
- rendered.js now exports __REGISTRY__ and __PARAMS__ alongside
  __RENDERED__ — preview/index.html reads all from single source
- Cross-validate all 11 template data contexts against official
  Gitea source (services/mailer/*.go + templates/mail/*.tmpl)
- Update all docs (README, AGENTS, CONTRIBUTING, 5 languages)
  to reflect new CLI workflow with create scaffolding command

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 12:26:44 +08:00

30 lines
541 B
Go

package main
import (
"fmt"
"os"
"github.com/urfave/cli/v2"
cmds "gitea-mail-templates/tools/cli"
)
func main() {
app := &cli.App{
Name: "tools",
Usage: "Gitea Mail Templates CLI — manage and preview email template themes",
UsageText: "tools <command> [args...] [--flags]",
Commands: []*cli.Command{
cmds.ListCommand(),
cmds.CreateCommand(),
cmds.DeleteCommand(),
cmds.PreviewCommand(),
},
}
if err := app.Run(os.Args); err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
os.Exit(1)
}
}