Wire `core module install/remove/list/update` commands to the marketplace.Installer from pkg/marketplace. Follows the exact pattern established by cmd/plugin/. - install: clone from Git repo with optional ed25519 verification - list: table output of installed modules - update: pull latest + re-verify manifest (supports --all) - remove: confirmation prompt then cleanup Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
859 B
Go
51 lines
859 B
Go
package module
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"forge.lthn.ai/core/go/pkg/cli"
|
|
"forge.lthn.ai/core/go/pkg/i18n"
|
|
)
|
|
|
|
func addListCommand(parent *cli.Command) {
|
|
listCmd := cli.NewCommand(
|
|
"list",
|
|
i18n.T("List installed modules"),
|
|
"",
|
|
func(cmd *cli.Command, args []string) error {
|
|
return runList()
|
|
},
|
|
)
|
|
|
|
parent.AddCommand(listCmd)
|
|
}
|
|
|
|
func runList() error {
|
|
_, st, inst, err := moduleSetup()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer st.Close()
|
|
|
|
installed, err := inst.Installed()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if len(installed) == 0 {
|
|
cli.Dim("No modules installed")
|
|
return nil
|
|
}
|
|
|
|
table := cli.NewTable("Code", "Name", "Version", "Repo")
|
|
for _, m := range installed {
|
|
table.AddRow(m.Code, m.Name, m.Version, m.Repo)
|
|
}
|
|
|
|
fmt.Println()
|
|
table.Render()
|
|
fmt.Println()
|
|
cli.Dim(fmt.Sprintf("%d module(s) installed", len(installed)))
|
|
|
|
return nil
|
|
}
|