result

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: Apache-2.0 Imports: 5 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Describe

func Describe(name, shortDesc string)

Describe prints the name in color, and the shortDesc using normal color. A newline is appended.

func PrintError

func PrintError(message string)

PrintError prints an error message. A newline is appended.

func PrintInfo

func PrintInfo(message string)

PrintInfo prints an info message. A newline is appended.

func PrintOK

func PrintOK(message string)

PrintOK prints a success message. A newline is appended.

func PrintRed

func PrintRed(message string)

PrintRed prints a message in red. A newline is appended.

Types

type Result

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

Result type

func New

func New(status Status, message string) Result

New constructs a Result object.

func NewCreated

func NewCreated(message string) Result

NewCreated constructs a Created Result object

func NewError

func NewError(message string) Result

NewError constructs an Error Result object

func NewInfo

func NewInfo(message string) Result

NewInfo constructs an Info Result object

func NewRemoved

func NewRemoved(message string) Result

NewRemoved constructs a Removed Result object

func NewUnchanged

func NewUnchanged(message string) Result

NewUnchanged constructs an Unchanged Result object

func NewUpdated

func NewUpdated(message string) Result

NewUpdated constructs an Updated Result object

func Run

func Run(runner func() Result) Result

Run executes a treatement and append the time spent to the result message

func (Result) IsCreated

func (result Result) IsCreated() bool

IsCreated function

func (Result) IsError

func (result Result) IsError() bool

IsError function

func (Result) IsFailure

func (result Result) IsFailure() bool

IsFailure function

func (Result) IsInfo

func (result Result) IsInfo() bool

IsInfo function

func (Result) IsRemoved

func (result Result) IsRemoved() bool

IsRemoved function

func (Result) IsSuccess

func (result Result) IsSuccess() bool

IsSuccess function

func (Result) IsUnchanged

func (result Result) IsUnchanged() bool

IsUnchanged function

func (Result) IsUpdated

func (result Result) IsUpdated() bool

IsUpdated function

func (Result) Message

func (result Result) Message() string

Message getter

func (Result) Print

func (result Result) Print()

Print prints a result.

func (Result) SetMessage

func (result Result) SetMessage(message string)

SetMessage setter

func (Result) StandardizeMessage

func (result Result) StandardizeMessage(name, value string) Result

StandardizeMessage constructs a Result object with a standardized message

func (Result) Status

func (result Result) Status() Status

Status getter

type Set

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

Set helps managing a set of Result

func NewSet

func NewSet(results []Result, message string) Set

NewSet constructor.

func (*Set) Add

func (results *Set) Add(res Result) Set

Add a new result to the result set. The result set is returned for convinience.

func (Set) DefaultMessage

func (results Set) DefaultMessage() string

DefaultMessage computes a default message based on the object state.

func (Set) IsEmpty

func (results Set) IsEmpty() bool

IsEmpty checks if the set contains NO result.

func (Set) IsSuccess

func (results Set) IsSuccess() bool

IsSuccess checks if all the results are in success.

func (Set) Message

func (results Set) Message() string

Message getter. Returns a default message if no message is set.

func (Set) OverallResult

func (results Set) OverallResult() Result

OverallResult gets a result object for the all set.

func (Set) Print

func (results Set) Print()

Print prints a result.

func (*Set) SetMessage

func (results *Set) SetMessage(message string)

SetMessage setter.

func (Set) Size

func (results Set) Size() int

Size gets the number of results (both success and failures).

type Status

type Status int

Status

const (
	Created Status = iota
	Updated
	Unchanged
	Removed
	Info
	Error
)

func (Status) String

func (s Status) String() string

Jump to

Keyboard shortcuts

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