diff --git a/cmd/info.go b/cmd/info.go index 535d8f3..e5d88e7 100644 --- a/cmd/info.go +++ b/cmd/info.go @@ -3,27 +3,30 @@ package cmd import ( "database/sql" "fmt" + "runtime/debug" "github.com/Jaculabilis/intake/core" "github.com/spf13/cobra" ) var infoCmd = &cobra.Command{ - Use: "info", + Use: "info [--build]", Short: "Print intake config", Long: `Print intake config as it would be used by other commands. `, Run: func(cmd *cobra.Command, args []string) { - info() + info(boolArg(cmd, "build")) }, DisableFlagsInUseLine: true, } func init() { 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("Data path: %s\n", dataPath) @@ -66,4 +69,13 @@ func info() { } else { 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) + } + } + } }