shared

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OutputFormatJson = "json"
	OutputFormatText = "text"

	FlagDebug        = "debug"
	FlagOutputFormat = "output-format"
)

Variables

View Source
var (
	ErrParse      = ErrorFactory(1)("parse-error")
	ErrApi        = ErrorFactory(2)("api-error")
	ErrOp         = ErrorFactory(3)("op-error")
	ErrDependency = ErrorFactory(4)("dependency-error")
)

Functions

func ErrorFactory

func ErrorFactory(code int) func(cause string) *LabError

func HandledJson

func HandledJson(raw []byte, err error) func(f CombinedJsonOutputHandler) (interface{}, error)

Types

type CombinedJsonOutputHandler

type CombinedJsonOutputHandler func(map[string]interface{}) (interface{}, error)

type ExtraArgs

type ExtraArgs struct {
	OutputFormat string
	Debug        bool
}

func (*ExtraArgs) InjectExtraArgs

func (ea *ExtraArgs) InjectExtraArgs(cmd *cobra.Command)

type JsonHandler

type JsonHandler func(raw []byte, err error) OutputProcessor

func HandleOutput

func HandleOutput(printer MessagePrinter) JsonHandler

type LabError

type LabError struct {
	Cause    string
	ExitCode int
}

func (*LabError) Error

func (e *LabError) Error() string

type MessagePrinter

type MessagePrinter interface {
	Info(templateText string, args map[string]interface{})
	Debug(templateText string, args map[string]interface{})
	Fatal(exitCode int, templateText string, args map[string]interface{})
}

func WithConfig

func WithConfig(cmd *cobra.Command, opt *ExtraArgs) MessagePrinter

type OutputProcessor

type OutputProcessor func(CombinedJsonOutputHandler) (interface{}, error)

Jump to

Keyboard shortcuts

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