rootcmd

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package rootcmd provide common functions to hollow binaries and cli set up

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	App         string
	ConfigFile  string
	Debug       bool
	PrettyPrint bool
	// contains filtered or unexported fields
}

Options are the basic setting rootcmd needs or sets

func (*Options) GetConfigFile

func (o *Options) GetConfigFile() string

GetConfigFile returns the path to the config file

func (*Options) GetLogger

func (o *Options) GetLogger() *zap.SugaredLogger

GetLogger returns the zap.SugarLogger

func (*Options) InitConfig

func (o *Options) InitConfig()

InitConfig reads in config file and ENV variables if set.

func (*Options) SetupLogging

func (o *Options) SetupLogging(logger *zap.SugaredLogger)

SetupLogging is a common configuraion of a zap.SugaredLogger, set to the logger passed

type Root

type Root struct {
	Cmd     *cobra.Command
	Options *Options
}

Root contains a cobra.Command and options

func NewRootCmd

func NewRootCmd(app, short string) *Root

NewRootCmd returns a

func (*Root) Execute

func (r *Root) Execute() error

Execute is a vanity wrapper on cobra.Command.Execute()

func (*Root) InitFlags

func (r *Root) InitFlags()

InitFlags are the 3 common flags for rootcmd

func (*Root) ViperBindFlag

func (r *Root) ViperBindFlag(name, flag string)

ViperBindFlag provides a wrapper around the viper bindings that handles error checks

Jump to

Keyboard shortcuts

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