application

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 14 Imported by: 0

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

View Source
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

View Source
var DefaultAlignment = AlignLeft

DefaultAlignment is the default text alignment (left)

View Source
var DefaultTextColor = TextColor{
	Type: colorTypeFixed, Color: []supportedColor{ColorDefault},
}

DefaultTextColor is the default color (no color)

Functions

func FormatAlignedTextParts added in v0.5.0

func FormatAlignedTextParts(value string, width int, align Alignment) (string, string, string)

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(printValue string, textColor TextColor) any

GetColored returns the printValue wrapped in color codes based on the color string

func GetLink(text, url string) string

GetLink returns a terminal link if the url is not empty, otherwise it returns the text as is

func ParseData

func ParseData(data []byte) (interface{}, error)

ParseData parses JSON data into an interface{}

func PrintTable

func PrintTable(spec *Spec, fullData interface{}) error

PrintTable prints JSON data in tabular format based on the provided specification

func ReadData

func ReadData(dataFilePath string) ([]byte, error)

ReadData reads a data file

func ReadParseData

func ReadParseData(dataFilePath string) (interface{}, error)

ReadParseData reads a data file and parses it into an interface{}

func ReadSpec

func ReadSpec(specFile string) ([]byte, error)

ReadSpec reads a spec file

func Run

func Run(args []string) error

Run start application

func UnmarshalAsString added in v0.5.0

func UnmarshalAsString(data []byte) (string, error)

UnmarshalAsString attempts to unmarshal JSON data as a string

func UnmarshalAsStringArray added in v0.5.0

func UnmarshalAsStringArray(data []byte) ([]string, error)

UnmarshalAsStringArray attempts to unmarshal JSON data as an array of strings

func ValidateDataFile

func ValidateDataFile(args []string) (string, error)

ValidateDataFile validates the data file argument, ensuring that either a single file is provided or data is piped to stdin

func ValidateSpec

func ValidateSpec(spec *Spec) error

ValidateSpec validates that the spec meets minimum requirements

func ValidateSpecFile

func ValidateSpecFile(specFile string) string

ValidateSpecFile validates the spec file option

Types

type Alignment added in v0.3.0

type Alignment string

Alignment represents text alignment in a column

const (
	// AlignLeft aligns text to the left
	AlignLeft Alignment = "left"
	// AlignRight aligns text to the right
	AlignRight Alignment = "right"
	// AlignCenter aligns text to the center
	AlignCenter Alignment = "center"
)

type Arguments

type Arguments struct {
	SpecFile string
	DataFile string
	EnvSpec  string
}

Arguments holds the parsed CLI arguments

func ParseArguments

func ParseArguments(c *cli.Command) (Arguments, error)

ParseArguments parses CLI arguments, validates them into an Arguments struct

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

func ParseAndValidateSpec(data []byte) (*Spec, error)

ParseAndValidateSpec parses JSON data into a Spec and validates it

func ReadParseValidateSpec

func ReadParseValidateSpec(specFile, envSpec string) (*Spec, error)

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

func (s *TextColor) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler for TextColor

Jump to

Keyboard shortcuts

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