cli/cmd/plugin/cmd_info.go
Charon c340303314 refactor: flatten commands, extract php/ci to own repos (#2)
## Summary
- Extract PHP/Laravel commands to `core/php` repo (42 files, standalone module)
- Extract CI/release + SDK commands to `core/ci` repo (10 files)
- Remove `internal/variants/` build tag system entirely
- Move all 30 remaining command packages from `internal/cmd/` to top-level `cmd/`
- Rewrite `main.go` with direct imports — no more variant selection
- PHP and CI are now optional via commented import lines in main.go

Co-authored-by: Claude <developers@lethean.io>
Reviewed-on: #2
Co-authored-by: Charon <charon@lthn.ai>
Co-committed-by: Charon <charon@lthn.ai>
2026-02-16 14:45:06 +00:00

86 lines
1.8 KiB
Go

package plugin
import (
"fmt"
"path/filepath"
"forge.lthn.ai/core/go/pkg/cli"
"forge.lthn.ai/core/go/pkg/i18n"
"forge.lthn.ai/core/go/pkg/io"
"forge.lthn.ai/core/go/pkg/plugin"
)
func addInfoCommand(parent *cli.Command) {
infoCmd := cli.NewCommand(
"info <name>",
i18n.T("Show detailed plugin information"),
"",
func(cmd *cli.Command, args []string) error {
return runInfo(args[0])
},
)
infoCmd.Args = cli.ExactArgs(1)
parent.AddCommand(infoCmd)
}
func runInfo(name string) error {
basePath, err := pluginBasePath()
if err != nil {
return err
}
registry := plugin.NewRegistry(io.Local, basePath)
if err := registry.Load(); err != nil {
return err
}
cfg, ok := registry.Get(name)
if !ok {
return fmt.Errorf("plugin not found: %s", name)
}
// Try to load the manifest for extended information
loader := plugin.NewLoader(io.Local, basePath)
manifest, manifestErr := loader.LoadPlugin(name)
fmt.Println()
cli.Label("Name", cfg.Name)
cli.Label("Version", cfg.Version)
cli.Label("Source", cfg.Source)
status := "disabled"
if cfg.Enabled {
status = "enabled"
}
cli.Label("Status", status)
cli.Label("Installed", cfg.InstalledAt)
cli.Label("Path", filepath.Join(basePath, name))
if manifestErr == nil && manifest != nil {
if manifest.Description != "" {
cli.Label("Description", manifest.Description)
}
if manifest.Author != "" {
cli.Label("Author", manifest.Author)
}
if manifest.Entrypoint != "" {
cli.Label("Entrypoint", manifest.Entrypoint)
}
if manifest.MinVersion != "" {
cli.Label("Min Version", manifest.MinVersion)
}
if len(manifest.Dependencies) > 0 {
for i, dep := range manifest.Dependencies {
if i == 0 {
cli.Label("Dependencies", dep)
} else {
fmt.Printf(" %s\n", dep)
}
}
}
}
fmt.Println()
return nil
}