format

package
v0.0.0-...-7f90a9e Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const EnumInvalid = -1

EnumInvalid is the constant value that an enum gets assigned when it could not be parsed

Variables

View Source
var ColorizeDesc = color.New(color.FgHiBlack).SprintFunc()

ColorizeDesc colorizes the input string as "Description"

View Source
var ColorizeEnum = color.New(color.FgHiCyan).SprintFunc()

ColorizeEnum colorizes the input string as "Enum"

View Source
var ColorizeFalse = color.New(color.FgHiRed).SprintFunc()

ColorizeFalse colorizes the input string as "False"

View Source
var ColorizeNumber = color.New(color.FgHiBlue).SprintFunc()

ColorizeNumber colorizes the input string as "Number"

View Source
var ColorizeString = color.New(color.FgHiYellow).SprintFunc()

ColorizeString colorizes the input string as "String"

View Source
var ColorizeTrue = color.New(color.FgHiGreen).SprintFunc()

ColorizeTrue colorizes the input string as "True"

Functions

func BuildQuery

func BuildQuery(c types.ServiceConfig) string

BuildQuery converts the fields of a config object to a delimited query string

func ColorizeValue

func ColorizeValue(value string, isEnum bool) string

ColorizeValue colorizes the input string according to what type appears to be

func CreateEnumFormatter

func CreateEnumFormatter(names []string) types.EnumFormatter

CreateEnumFormatter creates a EnumFormatter struct

func GetConfigFormat

func GetConfigFormat(service types.Service) (reflect.Type, []fieldInfo)

func GetConfigMap

func GetConfigMap(service types.Service) (map[string]string, int)

GetConfigMap returns a string map of a given Config struct

func IsNumber

func IsNumber(value string) bool

IsNumber returns whether the specified string is number-like

func ParseBool

func ParseBool(value string, defaultValue bool) (parsedValue bool, ok bool)

ParseBool returns true for "1","true","yes" or false for "0","false","no" or defaultValue for any other value

func PrintBool

func PrintBool(value bool) string

PrintBool returns "Yes" if value is true, otherwise returns "No"

Types

type EnumFormatter

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

EnumFormatter is the helper methods for enum-like types

func (EnumFormatter) Names

func (ef EnumFormatter) Names() []string

Names is the list of the valid Enum string values

func (EnumFormatter) Parse

func (ef EnumFormatter) Parse(s string) int

Parse takes an enum mapped string and returns it's int representation or EnumInvalid (-1)

func (EnumFormatter) Print

func (ef EnumFormatter) Print(e int) string

Print takes a enum mapped int and returns it's string representation or "Invalid"

type NotifyFormat

type NotifyFormat int

NotifyFormat describes the format used in the notification body

const (
	// Markdown is the default notification format
	Markdown NotifyFormat = 0
)

Jump to

Keyboard shortcuts

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