cmd

package
v0.0.0-...-e04b804 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Defines the cli-interface commands available to the user.

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "",
	Short: "Short desc",
	Long:  `Long description`,
}

RootCmd represents the base command when called without any subcommands.

View Source
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

func Colorize(input interface{}, colorNum int, disabled bool) string

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 InitConfig

func InitConfig()

InitConfig reads in config file and ENV variables if set.

func ProfilingFinalizer

func ProfilingFinalizer()

Stop profiling and write cpu and memory profiling files if configured.

func ProfilingInitializer

func ProfilingInitializer()

Sets up program profiling.

func SetupLogger

func SetupLogger(enableColor bool) zerolog.Logger

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
	// Profiling output directory.  Only captured if set.
	ProfilingDir string
	// CPU profiling output file handle.
	ProfilingCPUFile *os.File
}

Default options that are available to all commands.

var RootConfig CmdRootOptions

type Stamp

type Stamp struct {
	InfoGoVersion  string
	InfoGoCompiler string
	InfoGOARCH     string
	InfoGOOS       string
	InfoBuildTime  string
	VCSRevision    string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL