cli

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cli

type Cli struct {
	Csv       bool
	Batch     bool
	Formatter Formatter
	In        *In
	Out       *Out
}

func New

func New(
	formatter Formatter,
	out, err io.Writer,
) *Cli

type CsvWriter

type CsvWriter struct {
	// contains filtered or unexported fields
}

func (*CsvWriter) Flush

func (w *CsvWriter) Flush()

func (*CsvWriter) Write

func (w *CsvWriter) Write(record ...string) error

type Formatter

type Formatter interface {
	FormatInt(i int) string
	FormatPercentage(p float64) string
	FormatTime(t time.Time) string
	// FormatDurationms formats a duration as milliseconds
	FormatDurationms(d time.Duration) string
	// FormatDurations formats a duration as seconds
	FormatDurations(d time.Duration) string
}

func DefaultFormatter

func DefaultFormatter() Formatter

type In

type In struct{}

func (*In) ParseDurationms

func (i *In) ParseDurationms(in string) (time.Duration, error)

func (*In) ParseDurations

func (i *In) ParseDurations(in string) (time.Duration, error)

func (*In) ParseInt

func (i *In) ParseInt(in string) (int, error)

func (*In) ParseTime

func (i *In) ParseTime(in string) (time.Time, error)

type Out

type Out struct {
	// contains filtered or unexported fields
}

func (*Out) Errorf

func (o *Out) Errorf(format string, a ...any)

func (*Out) FailAndExit

func (o *Out) FailAndExit(err error)

func (*Out) FailAndExitf

func (o *Out) FailAndExitf(format string, a ...any)

func (*Out) NewCsvWriter

func (o *Out) NewCsvWriter(comma rune) *CsvWriter

func (*Out) NewTabwriter

func (o *Out) NewTabwriter() *TabWriter

func (*Out) Printf

func (o *Out) Printf(format string, a ...any)

func (*Out) Println

func (o *Out) Println(a ...any)

type TabWriter

type TabWriter struct {
	// contains filtered or unexported fields
}

func (*TabWriter) Flush

func (w *TabWriter) Flush()

func (*TabWriter) Write

func (w *TabWriter) Write(record ...string) error

Jump to

Keyboard shortcuts

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