Merge pull request #362 from brunohms/add-print-short-version
Print short version (ansible friendly)mine
commit
8f46b9421e
|
|
@ -24,9 +24,9 @@ func printInfo() {
|
||||||
const sectionFmt = "%-15s "
|
const sectionFmt = "%-15s "
|
||||||
|
|
||||||
printLogo(color.Cyan)
|
printLogo(color.Cyan)
|
||||||
printTuple(sectionFmt, "Configuration", config.K9sConfigFile)
|
printTuple(sectionFmt, "Configuration", config.K9sConfigFile, color.Cyan)
|
||||||
printTuple(sectionFmt, "Logs", config.K9sLogs)
|
printTuple(sectionFmt, "Logs", config.K9sLogs, color.Cyan)
|
||||||
printTuple(sectionFmt, "Screen Dumps", config.K9sDumpDir)
|
printTuple(sectionFmt, "Screen Dumps", config.K9sDumpDir, color.Cyan)
|
||||||
}
|
}
|
||||||
|
|
||||||
func printLogo(c color.Paint) {
|
func printLogo(c color.Paint) {
|
||||||
|
|
|
||||||
|
|
@ -8,26 +8,41 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func versionCmd() *cobra.Command {
|
func versionCmd() *cobra.Command {
|
||||||
return &cobra.Command{
|
var short bool
|
||||||
|
|
||||||
|
command := cobra.Command{
|
||||||
Use: "version",
|
Use: "version",
|
||||||
Short: "Print version/build info",
|
Short: "Print version/build info",
|
||||||
Long: "Print version/build information",
|
Long: "Print version/build information",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
printVersion()
|
printVersion(short)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
command.PersistentFlags().BoolVarP(&short, "short", "s", false, "Prints K9s version info in short format")
|
||||||
|
|
||||||
|
return &command
|
||||||
}
|
}
|
||||||
|
|
||||||
func printVersion() {
|
func printVersion(short bool) {
|
||||||
const secFmt = "%-10s "
|
const secFmt = "%-10s "
|
||||||
|
var outputColor color.Paint
|
||||||
|
|
||||||
printLogo(color.Cyan)
|
if short {
|
||||||
printTuple(secFmt, "Version", version)
|
outputColor = -1
|
||||||
printTuple(secFmt, "Commit", commit)
|
} else {
|
||||||
printTuple(secFmt, "Date", date)
|
outputColor = color.Cyan
|
||||||
|
printLogo(outputColor)
|
||||||
|
}
|
||||||
|
printTuple(secFmt, "Version", version, outputColor)
|
||||||
|
printTuple(secFmt, "Commit", commit, outputColor)
|
||||||
|
printTuple(secFmt, "Date", date, outputColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
func printTuple(format, section, value string) {
|
func printTuple(format, section, value string, outputColor color.Paint) {
|
||||||
fmt.Printf(color.Colorize(fmt.Sprintf(format, section+":"), color.Cyan))
|
if outputColor != -1 {
|
||||||
fmt.Println(color.Colorize(value, color.White))
|
section = color.Colorize(fmt.Sprintf(section+":"), outputColor)
|
||||||
|
value = color.Colorize(value, color.White)
|
||||||
|
}
|
||||||
|
fmt.Println(fmt.Sprintf(format, section), value)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue