show

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SCHEMA_PLAIN = Schema{
		StatusCodeIcon: SchemaStatusCode{
			NONE: "",
			PASS: "",
			WARN: "",
			FAIL: "",
		},
		StatusCodeText: SchemaStatusCode{
			NONE: "%s",
			PASS: "%s",
			WARN: "%s",
			FAIL: "%s",
		},

		Cluster: "%s",
	}

	SCHEMA_COLOR = Schema{
		StatusCodeIcon: SchemaStatusCode{
			NONE: "",
			PASS: "✅ ",
			WARN: "🟧 ",
			FAIL: "❌ ",
		},
		StatusCodeText: SchemaStatusCode{
			NONE: "%s",
			PASS: "\033[32m%s\033[0m",
			WARN: "\033[33m%s\033[0m",
			FAIL: "\033[31m%s\033[0m",
		},
		Cluster: "\u001b[1m%s\u001b[0m",
	}

	SCHEMA = SCHEMA_PLAIN
)

Functions

func StatusIcon

func StatusIcon(x types.StatusCode) string

func StatusText

func StatusText(x types.StatusCode) string

Types

type ContraMap

type ContraMap[A, B any] struct{ T Printer[A] }

Builds printer for type B from printer of type A and contramap B -> A

func (ContraMap[A, B]) FMap

func (c ContraMap[A, B]) FMap(f func(B) A) Printer[B]

type FromShow

type FromShow[T any] func(T) ([]byte, error)

Lifts a printer function to Pinter interface

func (FromShow[T]) Show

func (f FromShow[T]) Show(x T) ([]byte, error)

type Prefix

type Prefix[T any] string

Prepend prefix

func (Prefix[T]) FMap

func (p Prefix[T]) FMap(f Printer[T]) Printer[T]

type Printer

type Printer[T any] interface {
	Show(T) ([]byte, error)
}

Generic printer that translates type T instance to sequence of bytes

func Cluster

func Cluster[T, A any](t Printer[T], a Printer[A], f UnApply2[T, []A, []A]) Printer[T]

func JSON

func JSON[T any]() Printer[T]

outputs json

func None

func None[T any]() Printer[T]

outputs nothing

func Region

func Region[T, A, B any](a Printer[A], b Printer[B], f UnApply2[T, []A, []B]) Printer[T]

type Printer2

type Printer2[T, A, B any] struct {
	A Printer[A]
	B Printer[B]
	UnApply2[T, A, B]
}

Build printer for product type

func (Printer2[T, A, B]) Show

func (p Printer2[T, A, B]) Show(x T) ([]byte, error)

type Schema

type Schema struct {
	StatusCodeIcon SchemaStatusCode
	StatusCodeText SchemaStatusCode
	Cluster        string
}

func (Schema) FmtForStatus

func (s Schema) FmtForStatus(c types.StatusCode) string

type SchemaStatusCode

type SchemaStatusCode struct {
	NONE string
	PASS string
	WARN string
	FAIL string
}

type Seq

type Seq[T any] struct{ T Printer[T] }

Build a printer for sequence

func (Seq[T]) Show

func (seq Seq[T]) Show(x []T) ([]byte, error)

type UnApply2

type UnApply2[T, A, B any] func(T) (A, B)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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