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") }