Documentation
¶
Overview ¶
Defines the cli-interface commands available to the user.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var RootCmd = &cobra.Command{ Use: "locallhost", Short: "Run locallhost server", Long: `Start a server on a configured port that returns info about http requests.`, Run: func(cmd *cobra.Command, args []string) { port := RootConfig.Port if port <= 0 { port = 8080 log.Warn().Msgf("Invalid port num %d, defaulting to %d", RootConfig.Port, port) } logInterfaces(port) log.Fatal().Err(server.Serve(port)).Msg("server encountered error") }, }
RootCmd represents the base command when called without any subcommands.
var VersionCmd = &cobra.Command{ Use: "version", Short: "Get version", Long: `Get the current version of tool`, Run: func(cmd *cobra.Command, args []string) { fmt.Println(RootCmd.Use + "+ Version: " + version) info, ok := debug.ReadBuildInfo() if !ok { log.Fatal().Msg("could not read build info") } stamp := retrieveStamp(info) fmt.Printf(" Built with %s on %s\n", stamp.InfoGoCompiler, stamp.InfoBuildTime) fmt.Printf(" VCS revision: %s\n", stamp.VCSRevision) fmt.Printf(" Go version %s, GOOS %s, GOARCH %s\n", info.GoVersion, stamp.InfoGOOS, stamp.InfoGOARCH) fmt.Print(" Dependencies:\n") for _, mod := range retrieveDepends(info) { fmt.Printf(" %s\n", mod) } }, }
Print out versions of packages in use. Chore() - Updated manually.
Functions ¶
func Colorize ¶
Colorize function from zerolog console.go file to replicate their coloring functionality. Source: https://github.com/rs/zerolog/blob/a21d6107dcda23e36bc5cfd00ce8fdbe8f3ddc23/console.go#L389 Replicated here because it's a private function.
func ConfigureLogger ¶
func ConfigureLogger(debug bool)
func Execute ¶
func Execute(ver string)
Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func SetupLogger ¶
Configure zerolog with some defaults and cleanup error formatting.
Types ¶
type CmdRootOptions ¶
type CmdRootOptions struct {
// log more information about what the tool is doing. Overrides --loglevel
Debug bool
// set log level
LogLevel string
// enable colorized output (default true). Set to false to disable")
Color bool
// HTTP port to listen on
Port int
}
Default options that are available to all commands.
var RootConfig CmdRootOptions