check / check (push) Failing after 17m39s
The value is the commit's date, which the Makefile and the Dockerfile stamp in, not the time of the build. The other labels gain one space so every value still starts in one column. Model: opus-5-5
60 lines
1.8 KiB
Go
60 lines
1.8 KiB
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"runtime"
|
|
|
|
"github.com/spf13/cobra"
|
|
"sneak.berlin/go/vaultik/internal/globals"
|
|
"sneak.berlin/go/vaultik/internal/ui"
|
|
)
|
|
|
|
// 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(cmd *cobra.Command, _ []string) {
|
|
writeVersion(commandUI(cmd))
|
|
},
|
|
}
|
|
|
|
return cmd
|
|
}
|
|
|
|
// writeVersion prints the version report through the UI writer. The
|
|
// report is the output this command exists to produce, so it is written
|
|
// plain (markers would corrupt the aligned report) via the writer's
|
|
// underlying stdout; --quiet silences it like any other non-error
|
|
// output.
|
|
func writeVersion(out *ui.Writer) {
|
|
if out.Quiet() {
|
|
return
|
|
}
|
|
|
|
w := out.Out()
|
|
|
|
_, _ = fmt.Fprintf(w, "vaultik %s\n", globals.Version)
|
|
_, _ = fmt.Fprintf(w, " commit: %s\n", globals.Commit)
|
|
_, _ = fmt.Fprintf(w, " commit date: %s\n", globals.CommitDate)
|
|
_, _ = fmt.Fprintf(w, " go: %s\n", runtime.Version())
|
|
_, _ = fmt.Fprintf(w, " os/arch: %s/%s\n", runtime.GOOS, runtime.GOARCH)
|
|
_, _ = fmt.Fprintf(w, " author: %s\n", globals.Author)
|
|
_, _ = fmt.Fprintf(w, " homepage: %s\n", globals.Homepage)
|
|
_, _ = fmt.Fprintf(w, " license: %s\n", globals.License)
|
|
|
|
if globals.IsDevVersion(globals.Version) {
|
|
_, _ = fmt.Fprintln(w)
|
|
_, _ = fmt.Fprintln(w,
|
|
"This is a development build: it was not built from a tagged")
|
|
_, _ = fmt.Fprintln(w,
|
|
"commit, so it carries no release version. Released binaries")
|
|
_, _ = fmt.Fprintf(w,
|
|
"are published at %s\n", globals.ReleasesURL)
|
|
_, _ = fmt.Fprintln(w,
|
|
"and report their tag on the first line above.")
|
|
}
|
|
}
|