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
Index ¶
- Constants
- Variables
- func FormatAlignedTextParts(value string, width int, align Alignment) (string, string, string)
- func GetColored(printValue string, textColor TextColor) any
- func GetLink(text, url string) string
- func ParseData(data []byte) (interface{}, error)
- func PrintTable(spec *Spec, fullData interface{}) error
- func ReadData(dataFilePath string) ([]byte, 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 StringOrStringArray
- type TextColor
Constants ¶
const ( // ColorDefault represents default color (no color) ColorDefault supportedColor = "default" // ColorRed represents red color ColorRed supportedColor = "red" // ColorGreen represents green color ColorGreen supportedColor = "green" // ColorBlue represents blue color ColorBlue supportedColor = "blue" // ColorYellow represents yellow color ColorYellow supportedColor = "yellow" // ColorMagenta represents magenta color ColorMagenta supportedColor = "magenta" // ColorCyan represents cyan color ColorCyan supportedColor = "cyan" // ColorWhite represents white color ColorWhite supportedColor = "white" // ColorBlack represents black color ColorBlack supportedColor = "black" // ColorHiRed represents high intensity red color ColorHiRed supportedColor = "hiRed" // ColorHiGreen represents high intensity green color ColorHiGreen supportedColor = "hiGreen" // ColorHiBlue represents high intensity blue color ColorHiBlue supportedColor = "hiBlue" // ColorHiYellow represents high intensity yellow color ColorHiYellow supportedColor = "hiYellow" // ColorHiMagenta represents high intensity magenta color ColorHiMagenta supportedColor = "hiMagenta" // ColorHiCyan represents high intensity cyan color ColorHiCyan supportedColor = "hiCyan" // ColorHiWhite represents high intensity white color ColorHiWhite supportedColor = "hiWhite" // ColorHiBlack represents high intensity black color ColorHiBlack supportedColor = "hiBlack" // ColorBgRed represents red background color ColorBgRed supportedColor = "bgRed" // ColorBgGreen represents green background color ColorBgGreen supportedColor = "bgGreen" // ColorBgBlue represents blue background color ColorBgBlue supportedColor = "bgBlue" // ColorBgYellow represents yellow background color ColorBgYellow supportedColor = "bgYellow" // ColorBgMagenta represents magenta background color ColorBgMagenta supportedColor = "bgMagenta" // ColorBgCyan represents cyan background color ColorBgCyan supportedColor = "bgCyan" // ColorBgWhite represents white background color ColorBgWhite supportedColor = "bgWhite" // ColorBgBlack represents black background color ColorBgBlack supportedColor = "bgBlack" // ColorHiBgRed represents high intensity red background color ColorHiBgRed supportedColor = "hiBgRed" // ColorHiBgGreen represents high intensity green background color ColorHiBgGreen supportedColor = "hiBgGreen" // ColorHiBgBlue represents high intensity blue background color ColorHiBgBlue supportedColor = "hiBgBlue" // ColorHiBgYellow represents high intensity yellow background color ColorHiBgYellow supportedColor = "hiBgYellow" // ColorHiBgMagenta represents high intensity magenta background color ColorHiBgMagenta supportedColor = "hiBgMagenta" // ColorHiBgCyan represents high intensity cyan background color ColorHiBgCyan supportedColor = "hiBgCyan" // ColorHiBgWhite represents high intensity white background color ColorHiBgWhite supportedColor = "hiBgWhite" // ColorHiBgBlack represents high intensity black background color ColorHiBgBlack supportedColor = "hiBgBlack" // ColorBold represents bold text ColorBold supportedColor = "bold" // ColorFaint represents faint text ColorFaint supportedColor = "faint" // ColorItalic represents italic text ColorItalic supportedColor = "italic" // ColorUnderline represents underlined text ColorUnderline supportedColor = "underline" // ColorBlinkSlow represents slow blinking text ColorBlinkSlow supportedColor = "blinkSlow" // ColorBlinkRapid represents rapid blinking text ColorBlinkRapid supportedColor = "blinkRapid" // ColorReverseVideo represents reverse video text ColorReverseVideo supportedColor = "reverseVideo" // ColorConcealed represents concealed text ColorConcealed supportedColor = "concealed" // ColorCrossedOut represents crossed out text ColorCrossedOut supportedColor = "crossedOut" )
Variables ¶
var DefaultAlignment = AlignLeft
DefaultAlignment is the default text alignment (left)
var DefaultTextColor = TextColor{ Type: colorTypeFixed, Color: []supportedColor{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
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 StringOrStringArray `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 TextColor `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 StringOrStringArray ¶ added in v0.3.0
type StringOrStringArray []string
StringOrStringArray is a custom type that can unmarshal from either a string or []string
func (*StringOrStringArray) UnmarshalJSON ¶ added in v0.3.0
func (s *StringOrStringArray) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler for StringOrStringArray
type TextColor ¶ added in v0.5.0
type TextColor struct {
Type colorType
Color []supportedColor `json:"color"`
}
TextColor represents text color specification
func (*TextColor) UnmarshalJSON ¶ added in v0.5.0
UnmarshalJSON implements json.Unmarshaler for TextColor