internal

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotPiped = errors.New("no piped input")
)
View Source
var ParseFlags = func(f *flag.FlagSet, args []string) error {
	return f.Parse(args)
}

parseFlags if a variable function that parses the command line arguments. This is a variable so that it can be replaced in tests to avoid side effects.

Functions

This section is empty.

Types

type IndentWriter

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

IndentWriter is a wrapper around an io.Writer that will consistently indent output and providing methods to simplify the writing of text output containing indented sections and the handling of errors.

The IndentWriter is not thread-safe and should not be used concurrently.

If the underlying writer returns an error, the error is stored in the IndentWriter and no further output is written by any IndentWriter methods.

func (*IndentWriter) Write

func (w *IndentWriter) Write(s string, args ...any)

Write writes the specified arguments to the output writer. If the writer is in an error state, no output is written.

One or more arguments may be provided. If more than one argument is provided, the first argument is treated as a string to be used as a format string with the remaining arguments supplied as values.

If not yet written, the current indent string is written to the output writer before the specified arguments.

No newline is appended to the output.

func (*IndentWriter) WriteIndented

func (w *IndentWriter) WriteIndented(fn func())

WriteIndented calls the specified function with the indent string increased by two spaces. The indent is restored to its original value after the function returns.

func (*IndentWriter) WriteLn

func (w *IndentWriter) WriteLn(args ...any)

WriteLn writes the specified arguments with a newline appended. Different numbers of arguments are treated differently:

no arguments          only a newline is written.

one argument          the argument is written and a new-line appended.

multiple arguments    the first argument must be a string
                      to be used as a format string with the
                      remaining arguments supplied as values.

If the writer is in an error state, no output is written.

If not yet written, the current indent string is written to the output writer before the specified arguments.

func (*IndentWriter) WriteXMLElement

func (w *IndentWriter) WriteXMLElement(fn func(), el string, attrs ...string)

WriteXMLElement writes an XML element with optional attributes. The content is written by calling the specified function with the indent increased by two spaces. The element is closed with the appropriate end tag.

type Options

type Options struct{}

Options is a struct that implements a parser for the program options.

func (*Options) Parse

func (o *Options) Parse() (interface{ Run(*Options) int }, error)

parse is a method that parses the command line arguments and returns the appropriate command to run (if any).

Jump to

Keyboard shortcuts

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