pluginctl/version.go
Felipe Martin fd6e4a4513
Initial implementation of pluginctl CLI tool
- Add comprehensive info command with plugin manifest parsing -
Implement global --plugin-path flag and PLUGINCTL_PLUGIN_PATH env var -
Add full test suite with fixtures for various plugin configurations -
Set up build system with Makefile, goreleaser, and golangci-lint -
Include development tools with pinned versions for reproducible builds

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-08 14:30:09 +02:00

40 lines
852 B
Go

package main
import (
"fmt"
"runtime/debug"
)
// RunVersionCommand implements the 'version' command functionality.
func RunVersionCommand(args []string) error {
version := getVersion()
fmt.Printf("pluginctl version %s\n", version)
return nil
}
// getVersion returns the version information from build info.
func getVersion() string {
info, ok := debug.ReadBuildInfo()
if !ok {
return "unknown"
}
// First try to get version from main module
if info.Main.Version != "" && info.Main.Version != "(devel)" {
return info.Main.Version
}
// Look for version in build settings (set by goreleaser)
for _, setting := range info.Settings {
if setting.Key == "vcs.revision" {
// Return short commit hash if no version tag
if len(setting.Value) >= 7 {
return setting.Value[:7]
}
return setting.Value
}
}
return "dev"
}