Include build info in info command
This commit is contained in:
parent
46db4dd735
commit
b42d425873
18
cmd/info.go
18
cmd/info.go
@ -3,27 +3,30 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"runtime/debug"
|
||||||
|
|
||||||
"github.com/Jaculabilis/intake/core"
|
"github.com/Jaculabilis/intake/core"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var infoCmd = &cobra.Command{
|
var infoCmd = &cobra.Command{
|
||||||
Use: "info",
|
Use: "info [--build]",
|
||||||
Short: "Print intake config",
|
Short: "Print intake config",
|
||||||
Long: `Print intake config as it would be used by other commands.
|
Long: `Print intake config as it would be used by other commands.
|
||||||
`,
|
`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
info()
|
info(boolArg(cmd, "build"))
|
||||||
},
|
},
|
||||||
DisableFlagsInUseLine: true,
|
DisableFlagsInUseLine: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(infoCmd)
|
rootCmd.AddCommand(infoCmd)
|
||||||
|
|
||||||
|
infoCmd.Flags().Bool("build", false, "Include exact build settings")
|
||||||
}
|
}
|
||||||
|
|
||||||
func info() {
|
func info(buildInfo bool) {
|
||||||
fmt.Printf("Revision: %s\n", core.GetRevInfo())
|
fmt.Printf("Revision: %s\n", core.GetRevInfo())
|
||||||
|
|
||||||
fmt.Printf("Data path: %s\n", dataPath)
|
fmt.Printf("Data path: %s\n", dataPath)
|
||||||
@ -66,4 +69,13 @@ func info() {
|
|||||||
} else {
|
} else {
|
||||||
fmt.Printf("Items: %d\n", items)
|
fmt.Printf("Items: %d\n", items)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if buildInfo {
|
||||||
|
fmt.Printf("Build settings:\n")
|
||||||
|
if info, ok := debug.ReadBuildInfo(); ok {
|
||||||
|
for _, setting := range info.Settings {
|
||||||
|
fmt.Printf(" %s=%s\n", setting.Key, setting.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user