From 6bc0f98979e31261ac709ecfa3c3570ceb520036 Mon Sep 17 00:00:00 2001 From: Alex Dunmow Date: Sun, 7 Jun 2026 15:25:00 +0800 Subject: [PATCH] refactor(ninja): thread tags through upsertPluginMod Extend upsertPluginMod signature to accept tags parameter (positional arg 7, between categories and private). Update the single call site to pass nil. Add tags serialization in writeMod, mirroring the categories pattern. Co-Authored-By: Claude Opus 4.7 --- cmd/ninja/cmd/plugin.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/ninja/cmd/plugin.go b/cmd/ninja/cmd/plugin.go index 1b8eaa8..063911e 100644 --- a/cmd/ninja/cmd/plugin.go +++ b/cmd/ninja/cmd/plugin.go @@ -385,7 +385,7 @@ func newPluginInitCmd() *cobra.Command { if private { modScope = "" } - if err := upsertPluginMod(modScope, name, displayName, description, kind, cats, private); err != nil { + if err := upsertPluginMod(modScope, name, displayName, description, kind, cats, nil, private); err != nil { return err } fmt.Println("plugin.mod updated") @@ -975,7 +975,7 @@ func submodulePaths(repoDir string) []string { return paths } -func upsertPluginMod(scope, name, displayName, description, kind string, categories []string, private bool) error { +func upsertPluginMod(scope, name, displayName, description, kind string, categories, tags []string, private bool) error { const file = "plugin.mod" existing, _ := os.ReadFile(file) mod, _ := core.ParseModFull(existing) @@ -991,6 +991,7 @@ func upsertPluginMod(scope, name, displayName, description, kind string, categor mod.Plugin.Description = description mod.Plugin.Kind = kind mod.Plugin.Categories = categories + mod.Plugin.Tags = tags mod.Plugin.Private = private return writeMod(file, mod) } @@ -1017,6 +1018,13 @@ func writeMod(path string, m *core.ModFile) error { } b.WriteString(fmt.Sprintf("categories = [%s]\n", strings.Join(quoted, ", "))) } + if len(m.Plugin.Tags) > 0 { + quoted := make([]string, len(m.Plugin.Tags)) + for i, t := range m.Plugin.Tags { + quoted[i] = fmt.Sprintf("%q", t) + } + b.WriteString(fmt.Sprintf("tags = [%s]\n", strings.Join(quoted, ", "))) + } if m.Plugin.Private { b.WriteString("private = true\n") }