version

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VersionCmd = &cobra.Command{
	Use:     "version",
	Aliases: []string{"v"},
	Args:    cobra.NoArgs,
	Short:   "Print the version",
	Long:    `Output the version of the CLI.`,
	Example: `  > kw version
  v1.2.3

  > kw version -o json
  {"major":"v1","minor":"2","gitVersion":"v1.2.3","gitCommit":"76c01d5337fc9de6e053b4e5bafd5239c8b7a973","gitTreeState":"dirty","buildDate":"2024-04-26T11:29:39+02:00","goVersion":"go1.22.2","compiler":"gc","platform":"darwin/arm64"}

  > kw version -o yaml
  buildDate: "2024-04-26T11:29:39+02:00"
  compiler: gc
  gitCommit: 76c01d5337fc9de6e053b4e5bafd5239c8b7a973
  gitTreeState: dirty
  gitVersion: v1.2.3
  goVersion: go1.22.2
  major: v1
  minor: "2"
  platform: darwin/arm64`,
	Run: func(cmd *cobra.Command, args []string) {
		ver := version.Get()
		switch output {
		case libutils.OUTPUT_TEXT:
			cmd.Print(ver.String())
		case libutils.OUTPUT_JSON:
			data, err := json.Marshal(ver)
			if err != nil {
				libutils.Fatal(1, "error converting version to json: %w\n", err)
			}
			cmd.Println(string(data))
		case libutils.OUTPUT_YAML:
			data, err := yaml.Marshal(ver)
			if err != nil {
				libutils.Fatal(1, "error converting version to yaml: %w\n", err)
			}
			cmd.Print(string(data))
		default:
			libutils.Fatal(1, "unknown output format '%s'", string(output))
		}
	},
}

VersionCmd represents the version command

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL