github.com/TykTechnologies/tyk/cli/version
No package summary is available.
Package
Files: 1. Third party imports: 1. Imports from organisation: 0. Tests: 0. Benchmarks: 0.
Constants
const (
cmdName = "version"
cmdDesc = "Version and build information"
)
Types
runtimeInfo
This type doesn't have documentation.
| Field name | Field type | Comment |
|---|---|---|
| Os |
|
No comment on field. |
| Arch |
|
No comment on field. |
| Version |
|
No comment on field. |
type runtimeInfo struct {
Os string
Arch string
Version string
}
versionInfo
This type doesn't have documentation.
| Field name | Field type | Comment |
|---|---|---|
| Version |
|
No comment on field. |
| BuiltBy |
|
No comment on field. |
| BuildDate |
|
No comment on field. |
| Commit |
|
No comment on field. |
| Go |
|
Go contains build related information |
| asJson |
|
Flags, unexposed |
type versionInfo struct {
Version string
BuiltBy string
BuildDate string
Commit string
// Go contains build related information
Go runtimeInfo
// Flags, unexposed
asJson *bool
}
Functions
func AddTo
AddTo initializes a version info object.
func AddTo(app *kingpin.Application) {
cmd := app.Command(cmdName, cmdDesc)
info := &versionInfo{
Version: build.Version,
BuiltBy: build.BuiltBy,
BuildDate: build.BuildDate,
Commit: build.Commit,
Go: runtimeInfo{
Os: runtime.GOOS,
Arch: runtime.GOARCH,
Version: runtime.Version(),
},
asJson: cmd.Flag("json", "Output in JSON format").Bool(),
}
cmd.Action(info.Run)
}
Cognitive complexity: 2, Cyclomatic complexity: 1
func (*versionInfo) Run
Run is the entry point for printing out version information.
func (v *versionInfo) Run(ctx *kingpin.ParseContext) (err error) {
if *v.asJson {
out, err := json.MarshalIndent(v, "", " ")
if err != nil {
return err
}
fmt.Println(string(out))
return nil
}
fmt.Println(v)
return nil
}
Cognitive complexity: 4, Cyclomatic complexity: 3
func (*versionInfo) String
String implements fmt.Stringer for the version info.
func (v *versionInfo) String() string {
var output strings.Builder
output.WriteString("Release version: " + v.Version + "\n")
output.WriteString("Built by: " + v.BuiltBy + "\n")
output.WriteString("Build date: " + v.BuildDate + "\n")
output.WriteString("Commit: " + v.Commit + "\n")
output.WriteString("Go version: " + v.Go.Version + "\n")
output.WriteString("OS/Arch: " + v.Go.Os + "/" + v.Go.Arch + "\n")
return output.String()
}
Cognitive complexity: 0, Cyclomatic complexity: 1