Documentation
¶
Overview ¶
Package version provides the version command.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Commit = "none" Date = "unknown" BuiltBy = "unknown" )
These variables are set via -ldflags during the build process. Example: -ldflags "-X github.com/contextvibes/cli/cmd/version.Commit=$(git rev-parse HEAD)".
View Source
var VersionCmd = &cobra.Command{ Use: "version", Short: "Print the version and build information", RunE: func(cmd *cobra.Command, _ []string) error { if shortFlag { fmt.Fprintln(cmd.OutOrStdout(), globals.AppVersion) return nil } info := Info{ Version: globals.AppVersion, Commit: Commit, Date: Date, GoVersion: runtime.Version(), OS: runtime.GOOS, Arch: runtime.GOARCH, BuiltBy: BuiltBy, } if jsonFlag { enc := json.NewEncoder(cmd.OutOrStdout()) enc.SetIndent("", " ") return enc.Encode(info) } if yamlFlag { enc := yaml.NewEncoder(cmd.OutOrStdout()) return enc.Encode(info) } fmt.Fprintf(cmd.OutOrStdout(), "ContextVibes CLI\n") fmt.Fprintf(cmd.OutOrStdout(), " Version: %s\n", info.Version) fmt.Fprintf(cmd.OutOrStdout(), " Commit: %s\n", info.Commit) fmt.Fprintf(cmd.OutOrStdout(), " Built: %s\n", info.Date) fmt.Fprintf(cmd.OutOrStdout(), " Go Version: %s\n", info.GoVersion) fmt.Fprintf(cmd.OutOrStdout(), " OS/Arch: %s/%s\n", info.OS, info.Arch) return nil }, }
VersionCmd represents the version command.
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct {
Version string `json:"version" yaml:"version"`
Commit string `json:"commit" yaml:"commit"`
Date string `json:"date" yaml:"date"`
GoVersion string `json:"goVersion" yaml:"goVersion"`
OS string `json:"os" yaml:"os"`
Arch string `json:"arch" yaml:"arch"`
BuiltBy string `json:"builtBy" yaml:"builtBy"`
}
Info represents the build information.
Click to show internal directories.
Click to hide internal directories.