Documentation
¶
Overview ¶
Package application run the application
Package application run the application ¶
Package application run the application ¶
Package application run the application ¶
Package application run the application ¶
Package application run the application ¶
Package application run the application ¶
Package application run the application ¶
Package application run the application ¶
Package application run the application ¶
Package application run the application ¶
Package application run the application
Index ¶
- Constants
- Variables
- func FormatAlignedTextParts(value string, width int, align Alignment) (string, string, string)
- func GetColored(originalValue, printValue string, textColor TextColorSpec) any
- func GetLink(text, url string) string
- func PrintTable(spec *Spec, fullData interface{}) error
- func ReadParseData(dataFilePath string) (interface{}, error)
- func ReadSpec(specFile string) ([]byte, error)
- func Run(args []string) error
- func UnmarshalAsString(data []byte) (string, error)
- func UnmarshalAsStringArray(data []byte) ([]string, error)
- func ValidateDataFile(args []string) (string, error)
- func ValidateSpec(spec *Spec) error
- func ValidateSpecFile(specFile string) string
- type Alignment
- type Arguments
- type Column
- type Spec
- type StringList
- type TextColorSpec
Constants ¶
const ( // ColorDefault represents default color (no color) ColorDefault string = "default" // ColorRed represents red color ColorRed string = "red" // ColorGreen represents green color ColorGreen string = "green" // ColorBlue represents blue color ColorBlue string = "blue" // ColorYellow represents yellow color ColorYellow string = "yellow" // ColorMagenta represents magenta color ColorMagenta string = "magenta" // ColorCyan represents cyan color ColorCyan string = "cyan" // ColorWhite represents white color ColorWhite string = "white" // ColorBlack represents black color ColorBlack string = "black" // ColorHiRed represents high intensity red color ColorHiRed string = "hiRed" // ColorHiGreen represents high intensity green color ColorHiGreen string = "hiGreen" // ColorHiBlue represents high intensity blue color ColorHiBlue string = "hiBlue" // ColorHiYellow represents high intensity yellow color ColorHiYellow string = "hiYellow" // ColorHiMagenta represents high intensity magenta color ColorHiMagenta string = "hiMagenta" // ColorHiCyan represents high intensity cyan color ColorHiCyan string = "hiCyan" // ColorHiWhite represents high intensity white color ColorHiWhite string = "hiWhite" // ColorHiBlack represents high intensity black color ColorHiBlack string = "hiBlack" // ColorBgRed represents red background color ColorBgRed string = "bgRed" // ColorBgGreen represents green background color ColorBgGreen string = "bgGreen" // ColorBgBlue represents blue background color ColorBgBlue string = "bgBlue" // ColorBgYellow represents yellow background color ColorBgYellow string = "bgYellow" // ColorBgMagenta represents magenta background color ColorBgMagenta string = "bgMagenta" // ColorBgCyan represents cyan background color ColorBgCyan string = "bgCyan" // ColorBgWhite represents white background color ColorBgWhite string = "bgWhite" // ColorBgBlack represents black background color ColorBgBlack string = "bgBlack" // ColorHiBgRed represents high intensity red background color ColorHiBgRed string = "hiBgRed" // ColorHiBgGreen represents high intensity green background color ColorHiBgGreen string = "hiBgGreen" // ColorHiBgBlue represents high intensity blue background color ColorHiBgBlue string = "hiBgBlue" // ColorHiBgYellow represents high intensity yellow background color ColorHiBgYellow string = "hiBgYellow" // ColorHiBgMagenta represents high intensity magenta background color ColorHiBgMagenta string = "hiBgMagenta" // ColorHiBgCyan represents high intensity cyan background color ColorHiBgCyan string = "hiBgCyan" // ColorHiBgWhite represents high intensity white background color ColorHiBgWhite string = "hiBgWhite" // ColorHiBgBlack represents high intensity black background color ColorHiBgBlack string = "hiBgBlack" // ColorBold represents bold text ColorBold string = "bold" // ColorFaint represents faint text ColorFaint string = "faint" // ColorItalic represents italic text ColorItalic string = "italic" // ColorUnderline represents underlined text ColorUnderline string = "underline" // ColorBlinkSlow represents slow blinking text ColorBlinkSlow string = "blinkSlow" // ColorBlinkRapid represents rapid blinking text ColorBlinkRapid string = "blinkRapid" // ColorReverseVideo represents reverse video text ColorReverseVideo string = "reverseVideo" // ColorConcealed represents concealed text ColorConcealed string = "concealed" // ColorCrossedOut represents crossed out text ColorCrossedOut string = "crossedOut" )
Variables ¶
var DefaultAlignment = AlignLeft
DefaultAlignment is the default text alignment (left)
var DefaultTextColor = TextColorSpec{ Type: colorTypeFixed, Default: StringList{ColorDefault}, }
DefaultTextColor is the default color (no color)
Functions ¶
func FormatAlignedTextParts ¶ added in v0.5.0
FormatAlignedTextParts formats the given value according to the specified width and alignment, returning the prefix, formatted value, and suffix for proper alignment in a table cell.
func GetColored ¶ added in v0.5.0
func GetColored(originalValue, printValue string, textColor TextColorSpec) any
GetColored returns the printValue wrapped in color codes based on the color string
func GetLink ¶ added in v0.4.0
GetLink returns a terminal link if the url is not empty, otherwise it returns the text as is
func PrintTable ¶
PrintTable prints JSON data in tabular format based on the provided specification
func ReadParseData ¶
ReadParseData reads a data file and parses it into an interface{}
func UnmarshalAsString ¶ added in v0.5.0
UnmarshalAsString attempts to unmarshal JSON data as a string
func UnmarshalAsStringArray ¶ added in v0.5.0
UnmarshalAsStringArray attempts to unmarshal JSON data as an array of strings
func ValidateDataFile ¶
ValidateDataFile validates the data file argument, ensuring that either a single file is provided or data is piped to stdin
func ValidateSpec ¶
ValidateSpec validates that the spec meets minimum requirements
func ValidateSpecFile ¶
ValidateSpecFile validates the spec file option
Types ¶
type Alignment ¶ added in v0.3.0
type Alignment string
Alignment represents text alignment in a column
type Column ¶
type Column struct {
Path StringList `json:"path" validate:"required"`
Title string `json:"title"`
MinWidth int `json:"minWidth" validate:"min=0,ltefield=MaxWidth"`
MaxWidth int `json:"maxWidth" validate:"min=0,gtefield=MinWidth"`
Align Alignment `json:"align" validate:"omitempty,oneof=left right center"`
URLPath string `json:"urlPath"`
Color TextColorSpec `json:"color"`
Width int
}
Column represents a column specification
type Spec ¶
type Spec struct {
DataPath string `json:"dataPath"`
Columns []Column `json:"columns" validate:"required,min=1,dive"`
}
Spec represents the specification structure
func ParseAndValidateSpec ¶
ParseAndValidateSpec parses JSON data into a Spec and validates it
func ReadParseValidateSpec ¶
ReadParseValidateSpec reads a spec file, parses it, and validates it
type StringList ¶ added in v0.6.0
type StringList []string
StringList is a custom type that can unmarshal from either a string or []string
func (*StringList) UnmarshalJSON ¶ added in v0.6.0
func (s *StringList) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler for StringList
type TextColorSpec ¶ added in v0.6.0
type TextColorSpec struct {
Type colorType
Default StringList `json:"default"`
Conditions []struct {
When StringList `json:"when"`
Color StringList `json:"color"`
} `json:"conditions"`
}
TextColorSpec represents text color specification
func (*TextColorSpec) UnmarshalJSON ¶ added in v0.6.0
func (s *TextColorSpec) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler for TextColorSpec