- Add logger.go with public Logger variable and InitLogger function - Replace all fmt.Printf/fmt.Fprintf calls with structured Logger.Info/Logger.Error - Initialize logger in main function for consistent access across packages - Keep fmt.Errorf for proper error creation (standard Go practice) - Add tint dependency for colorized terminal output with timestamps - Convert user output to structured logging with key-value pairs - Update info command to use structured logging for plugin details - Update updateassets command to use structured progress logging - Update version command to use structured logging - Update authentication logging in client.go with structured fields - Update enable/disable commands to use structured logging - Remove unused fmt imports after conversion All output now uses slog with tint for beautiful, structured, colorized logging while maintaining proper error handling with fmt.Errorf for error creation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
41 lines
915 B
Go
41 lines
915 B
Go
package pluginctl
|
|
|
|
import (
|
|
"runtime/debug"
|
|
)
|
|
|
|
// RunVersionCommand implements the 'version' command functionality.
|
|
func RunVersionCommand(args []string) error {
|
|
version := GetVersion()
|
|
Logger.Info("pluginctl version", "version", 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
|
|
const shortHashLength = 7
|
|
if len(setting.Value) >= shortHashLength {
|
|
return setting.Value[:shortHashLength]
|
|
}
|
|
|
|
return setting.Value
|
|
}
|
|
}
|
|
|
|
return "dev"
|
|
}
|