package cli import ( "fmt" "os" "runtime" "github.com/spf13/cobra" "sneak.berlin/go/vaultik/internal/globals" ) // NewVersionCommand creates the version command func NewVersionCommand() *cobra.Command { cmd := &cobra.Command{ Use: "version", Short: "Print version information", Long: `Print version, git commit, and build information for vaultik.`, Args: cobra.NoArgs, Run: func(_ *cobra.Command, _ []string) { _, _ = fmt.Fprintf(os.Stdout, "vaultik %s\n", globals.Version) _, _ = fmt.Fprintf(os.Stdout, " commit: %s\n", globals.Commit) _, _ = fmt.Fprintf(os.Stdout, " build date: %s\n", globals.CommitDate) _, _ = fmt.Fprintf(os.Stdout, " go: %s\n", runtime.Version()) _, _ = fmt.Fprintf(os.Stdout, " os/arch: %s/%s\n", runtime.GOOS, runtime.GOARCH) _, _ = fmt.Fprintf(os.Stdout, " author: %s\n", globals.Author) _, _ = fmt.Fprintf(os.Stdout, " homepage: %s\n", globals.Homepage) _, _ = fmt.Fprintf(os.Stdout, " license: %s\n", globals.License) if globals.Version == "dev" { _, _ = fmt.Fprintln(os.Stdout) _, _ = fmt.Fprintln(os.Stdout, "This is a development build (no version information embedded).") _, _ = fmt.Fprintln(os.Stdout, "Build a release binary with 'make vaultik' or download from") _, _ = fmt.Fprintln(os.Stdout, "https://sneak.berlin/go/vaultik for embedded version metadata.") } }, } return cmd }