version

package
v0.2.2-0...-13ba25a Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: Apache-2.0 Imports: 6 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version    = ""
	Commit     = ""
	VendorHash = ""
	BuildTags  = ""
)

nolint:gochecknoglobals

View Source
var (
	Cmd = &cobra.Command{
		Use:   "version",
		Short: "Print the app version",
		RunE: func(_ *cobra.Command, _ []string) error {
			info := newInfo()

			if !viper.GetBool(flagLong) {
				fmt.Println(info.Version + "-" + info.Commit)
				return nil
			}

			if viper.GetString(cli.OutputFlag) != "json" {
				fmt.Print(info)
				return nil
			}

			bz, err := json.Marshal(info)
			if err != nil {
				return err
			}

			fmt.Println(string(bz))
			return nil
		},
	}
)

nolint:gochecknoglobals

Functions

This section is empty.

Types

type Info

type Info struct {
	Version    string `json:"version"`
	Commit     string `json:"commit"`
	VendorHash string `json:"vendor_hash"`
	Go         string `json:"go"`
}

func (Info) String

func (i Info) String() string

Jump to

Keyboard shortcuts

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