chore: migrate mail themes to shared framework and locked upstream inputs
This commit is contained in:
1 parent
5c0589f6f6
commit
fec3ace600
225 files changed
+4718
-15807
No files matched your search
+14
-46
@@ -2,56 +2,24 @@ package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
|
||||
"gitea-mail-templates/tools/builder"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
"gitea-mail-templates/tools/preview"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// ListCommand returns the "list" subcommand.
|
||||
func ListCommand() *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "list",
|
||||
Usage: "List available theme styles in the target folder",
|
||||
UsageText: "go run . list [--folder <themes-dir>]",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "folder",
|
||||
Value: "../themes",
|
||||
Usage: "Path to the themes directory",
|
||||
},
|
||||
},
|
||||
Action: runList,
|
||||
}
|
||||
}
|
||||
|
||||
func runList(c *cli.Context) error {
|
||||
folder := c.String("folder")
|
||||
|
||||
themes, err := preview.DiscoverThemes(folder)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
absDir, _ := filepath.Abs(folder)
|
||||
fmt.Printf("\033[32m[I]\033[0m [Preview] Available styles in '%s' (%d):\n", filepath.Base(absDir), len(themes))
|
||||
|
||||
sort.Strings(themes)
|
||||
for _, t := range themes {
|
||||
count := 0
|
||||
filepath.Walk(filepath.Join(folder, t), func(path string, info os.FileInfo, err error) error {
|
||||
return &cli.Command{Name: "list", Usage: "List available theme manifests", Flags: []cli.Flag{&cli.StringFlag{Name: "folder", Value: "../themes"}}, Action: func(c *cli.Context) error {
|
||||
names, err := builder.Discover(c.String("folder"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, name := range names {
|
||||
t, err := builder.LoadTheme(filepath.Join(c.String("folder"), name))
|
||||
if err != nil {
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
if filepath.Ext(path) == ".tmpl" {
|
||||
count++
|
||||
}
|
||||
return nil
|
||||
})
|
||||
fmt.Printf("\033[32m[I]\033[0m [Preview] %-16s (%d .tmpl files)\n", t, count)
|
||||
}
|
||||
return nil
|
||||
fmt.Printf("%-16s %-8s %s\n", name, t.Mode, t.Description)
|
||||
}
|
||||
return nil
|
||||
}}
|
||||
}
|
||||
Reference in new issue
Block a user