cli/cmd/module/cmd.go
Claude 6a8bd92189
Some checks failed
Deploy / build (push) Failing after 4s
Security Scan / security (push) Successful in 15s
feat: add pkg/cli with TUI components (#14, #15)
Move pkg/cli from core/go to core/cli. Includes Frame AppShell,
Stream, TaskTracker, Tree, Rich Table. Update imports to v0.0.1
tagged deps and fix openpgp import path for go-crypt split.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 20:42:00 +00:00

55 lines
1.5 KiB
Go

// Package module provides CLI commands for managing marketplace modules.
//
// Commands:
// - install: Install a module from a Git repo
// - list: List installed modules
// - update: Update a module or all modules
// - remove: Remove an installed module
package module
import (
"os"
"path/filepath"
"forge.lthn.ai/core/cli/pkg/cli"
"forge.lthn.ai/core/go/pkg/i18n"
"forge.lthn.ai/core/go/pkg/marketplace"
"forge.lthn.ai/core/go/pkg/store"
)
// AddModuleCommands registers the 'module' command and all subcommands.
func AddModuleCommands(root *cli.Command) {
moduleCmd := &cli.Command{
Use: "module",
Short: i18n.T("Manage marketplace modules"),
}
root.AddCommand(moduleCmd)
addInstallCommand(moduleCmd)
addListCommand(moduleCmd)
addUpdateCommand(moduleCmd)
addRemoveCommand(moduleCmd)
}
// moduleSetup returns the modules directory, store, and installer.
// The caller must defer st.Close().
func moduleSetup() (string, *store.Store, *marketplace.Installer, error) {
home, err := os.UserHomeDir()
if err != nil {
return "", nil, nil, cli.Wrap(err, "failed to determine home directory")
}
modulesDir := filepath.Join(home, ".core", "modules")
if err := os.MkdirAll(modulesDir, 0755); err != nil {
return "", nil, nil, cli.Wrap(err, "failed to create modules directory")
}
dbPath := filepath.Join(modulesDir, "modules.db")
st, err := store.New(dbPath)
if err != nil {
return "", nil, nil, cli.Wrap(err, "failed to open module store")
}
inst := marketplace.NewInstaller(modulesDir, st)
return modulesDir, st, inst, nil
}