Files
GiteaMailTemplates/tools/cli/build.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

33 lines
1020 B
Go

package cli
import (
"gitea-mail-templates/tools/builder"
"gitea-mail-templates/tools/logging"
"gitea-mail-templates/tools/upstream"
"github.com/urfave/cli/v2"
"path/filepath"
)
func BuildCommand() *cli.Command {
return &cli.Command{Name: "build", Usage: "Generate installable themes from locked official inputs and shared controls", Flags: []cli.Flag{&cli.StringFlag{Name: "folder", Value: "../themes"}}, Action: func(c *cli.Context) error {
s, err := upstream.Prepare(c.Context, filepath.Dir(c.String("folder")))
if err != nil {
return err
}
filter, err := builder.Filter(c.Args().Slice())
if err != nil {
return err
}
packages, err := builder.BuildAll(c.String("folder"), s, filter)
if err != nil {
return err
}
output := filepath.Join(filepath.Dir(c.String("folder")), "build", "themes")
if err := builder.Write(output, s, packages); err != nil {
return err
}
logging.Info("Builder", "Built %d themes for %s at %s", len(packages), s.Lock.Tag, output)
return nil
}}
}