cli

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2018 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DebugLogConfig is used to generate a *zap.Logger for debug mode.
	DebugLogConfig = func() zap.Config {
		cfg := zap.NewProductionConfig()
		cfg.Level = zap.NewAtomicLevelAt(zapcore.DebugLevel)
		cfg.DisableStacktrace = true
		return cfg
	}()
	// VerboseLogConfig is used to generate a *zap.Logger for verbose mode.
	VerboseLogConfig = func() zap.Config {
		cfg := zap.NewDevelopmentConfig()
		cfg.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
		cfg.Level = zap.NewAtomicLevelAt(zapcore.InfoLevel)
		cfg.EncoderConfig.EncodeTime = func(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
			enc.AppendString(t.Local().Format("2006-01-02 15:04:05 MST"))
		}
		return cfg
	}()
)
View Source
var NopUI = &nopUIImpl{}

Functions

func AddLoggingFlags

func AddLoggingFlags(cmd *cobra.Command)

AddLoggingFlags sets "--debug" and "--verbose" flags to the given *cobra.Command instance.

func Close

func Close()

Close closes cli utilities.

func Debug

func Debug()

Debug sets a debug logger in global.

func IsDebug

func IsDebug() bool

IsDebug returns true if a debug logger is used.

func IsVerbose

func IsVerbose() bool

IsVerbose returns true if a verbose logger is used.

func Verbose

func Verbose()

Verbose sets a verbose logger in global.

Types

type IO

type IO struct {
	In  io.Reader
	Out io.Writer
	Err io.Writer
}

IO contains an input reader, an output writer and an error writer.

func DefaultIO

func DefaultIO() *IO

DefaultIO returns a standard IO object.

type RootDir

type RootDir string

RootDir represents a project root directory.

func (RootDir) BinDir

func (d RootDir) BinDir() string

BinDir returns the directory path contains executable binaries.

func (RootDir) Join

func (d RootDir) Join(elem ...string) string

Join joins path elements to the root directory.

func (RootDir) String

func (d RootDir) String() string

type UI

type UI interface {
	Section(msg string)
	Subsection(msg string)
	ItemSuccess(msg string)
	ItemSkipped(msg string)
	ItemFailure(msg string)
	Confirm(msg string) (bool, error)
}

UI is an interface for intaracting with the terminal.

func NewUI

func NewUI(io *IO) UI

NewUI creates a new UI instance.

func UIInstance

func UIInstance(io *IO) UI

UIInstance retuens a singleton UI instance.

Jump to

Keyboard shortcuts

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