cli

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DebugLevel defines debug log level.
	DebugLevel = zerolog.DebugLevel
	// InfoLevel defines info log level.
	InfoLevel = zerolog.InfoLevel
	// WarnLevel defines warn log level.
	WarnLevel = zerolog.WarnLevel
	// ErrorLevel defines error log level.
	ErrorLevel = zerolog.ErrorLevel
	// FatalLevel defines fatal log level.
	FatalLevel = zerolog.FatalLevel
	// PanicLevel defines panic log level.
	PanicLevel = zerolog.PanicLevel
	// NoLevel defines an absent log level.
	NoLevel = zerolog.NoLevel
	// Disabled disables the logger.
	Disabled = zerolog.Disabled
	// TraceLevel defines trace log level.
	TraceLevel = zerolog.TraceLevel
)

Variables

This section is empty.

Functions

func ApplicationStartFailed

func ApplicationStartFailed(l zerolog.Logger, err error)

func ApplicationStarted

func ApplicationStarted(l zerolog.Logger)

func ApplicationSuccefulStopped

func ApplicationSuccefulStopped(l zerolog.Logger)

func CombineStructs

func CombineStructs(structs ...interface{}) (interface{}, error)

func CopyStruct

func CopyStruct(src, dest interface{}) error

func JSON

func JSON(r io.Reader) (kong.Resolver, error)

func Run

func Run(cli interface{}, ctx context.Context, options ...Option)

Run executes the Run() method on the selected command, which must exist.

Types

type Cli

type Cli struct {
	// Common flags.
	LoggingFormat LoggingFormat `help:"Logging format (${enum}). Default value: \"${default}\"" enum:"json,text,coloredtext" default:"coloredtext"`
	LoggingLevel  LoggingLevel  `help:"Logging level (${enum})." enum:"debug,info,warn,error,fatal,panic,trace" default:"info"`
	LoggingOutput LoggingOutput `help:"Logging output (stderr,stdout,<path>)." default:"stderr"`

	// if the flag --config=<path> is defined, then config will be loaded
	Config kong.ConfigFlag `type:"path" help:"Config path."`
	// Used for showing version if defined --version flag
	Version kong.VersionFlag
}

type ConsoleWriter

type ConsoleWriter struct {
	// contains filtered or unexported fields
}

func NewConsoleWriter

func NewConsoleWriter() *ConsoleWriter

func (*ConsoleWriter) Format

func (c *ConsoleWriter) Format(f Format) *ConsoleWriter

func (*ConsoleWriter) Out

func (c *ConsoleWriter) Out(w io.Writer) *ConsoleWriter

func (*ConsoleWriter) Write

func (c *ConsoleWriter) Write(p []byte) (n int, err error)

type Format

type Format int
const (
	TextFormat Format = iota
	ColoredTextFormat
	JSONFormat
)

type LoggingFormat

type LoggingFormat string

func (LoggingFormat) AfterApply

func (l LoggingFormat) AfterApply(ctx *context.Context, writer *ConsoleWriter) error

type LoggingLevel

type LoggingLevel string

func (LoggingLevel) BeforeApply

func (l LoggingLevel) BeforeApply(ctx *context.Context) error

type LoggingOutput

type LoggingOutput string

func (LoggingOutput) AfterApply

func (l LoggingOutput) AfterApply(ctx *context.Context, writer *ConsoleWriter) (err error)

type Option

type Option func() kong.Option

func Env

func Env(prefix string) Option

Env inits environment names for flags. For example:

--some.value -> PREFIX_SOME_VALUE

func Name

func Name(name string) Option

Name sets application name.

func Paths

func Paths(paths ...string) Option

Path sets configuration pathes.

func Version

func Version(version string) Option

Version sets application version. It outputs when --version flag is defined.

Jump to

Keyboard shortcuts

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