Files
GiteaMailTemplates/tools/cli/upstream.go
T
KenanZhu c93f2bf8b2
Release / Validate Templates (push) Successful in 2m55s
Release / Package & Release (push) Skipped
Release / Remind to Update Release Documentation (push) Skipped
chore: simplify workflows and unify tool logging and mail presentation
2026-10-10 14:54:40 +08:00

32 lines
1.5 KiB
Go

package cli
import (
"gitea-mail-templates/tools/logging"
"gitea-mail-templates/tools/upstream"
"github.com/urfave/cli/v2"
)
func UpstreamCommand() *cli.Command {
return &cli.Command{Name: "upstream", Usage: "Prepare, synchronize or verify locked official build inputs", Subcommands: []*cli.Command{
{Name: "prepare", Usage: "Download missing immutable cache files from gitea.lock.json", Flags: []cli.Flag{&cli.StringFlag{Name: "root", Value: ".."}}, Action: func(c *cli.Context) error { _, err := upstream.Prepare(c.Context, c.String("root")); return err }},
{Name: "sync", Usage: "Review a new Gitea tag and regenerate the lock and cache", Flags: []cli.Flag{&cli.StringFlag{Name: "tag", Required: true}, &cli.StringFlag{Name: "root", Value: ".."}}, Action: func(c *cli.Context) error { return upstream.SyncRoot(c.Context, c.String("tag"), c.String("root")) }},
{Name: "verify", Usage: "Verify cached inputs against the repository lock offline", Flags: []cli.Flag{&cli.StringFlag{Name: "root", Value: ".."}}, Action: func(c *cli.Context) error {
s, err := upstream.LoadPinned(c.String("root"))
if err != nil {
return err
}
missing, err := upstream.MissingKeys(s)
if err != nil {
return err
}
logging.Info("Upstream", "%s: %d mail files, %d languages", s.Lock.Tag, len(s.Templates), len(s.Locales))
for _, lang := range s.Languages() {
if keys := missing[lang]; len(keys) > 0 {
logging.Warn("Locale", "%s -> en-US: %v", lang, keys)
}
}
return nil
}},
}}
}