application

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 12 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 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"`

	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 string, 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

Jump to

Keyboard shortcuts

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