cli

package
v0.0.0-...-7eed66f Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadCredentials

func ReadCredentials(c *Cli, registryAuth *types.AuthConfig)

ReadCredentials ask the user to enter his login and password and stores the value in the given registryAuth

func ReadPassword

func ReadPassword(a ...interface{}) (int, error)

ReadPassword reads from the terminal without echoing input

Types

type Cli

type Cli struct {
	In  io.Reader
	Out io.WriteCloser
	Err io.WriteCloser
}

Cli holds reader and writer to interact wih user

type InputReader

type InputReader func(a ...interface{}) (int, error)

InputReader defines a method that can read into a string

type Printer

type Printer interface {
	PrintAll(wait bool) error
}

Printer defines common method to print rows of results

type TabPrinter

type TabPrinter struct {
	Separator byte
	Width     int
	Wait      bool
	Template  string
	// contains filtered or unexported fields
}

TabPrinter prints data in tabular format. It computes column width and support incremental data population

func NewTabPrinter

func NewTabPrinter(writer io.Writer, reader io.Reader, options ...TabPrinterOption) *TabPrinter

NewTabPrinter returns a TabPrinter with sane defaults

func (*TabPrinter) Append

func (t *TabPrinter) Append(row []string)

Append adds a row of data to the collection of data to print

func (*TabPrinter) BulkAppend

func (t *TabPrinter) BulkAppend(rows [][]string)

BulkAppend adds a serie of rows of data to the collection of data to print

func (*TabPrinter) PrintAll

func (t *TabPrinter) PrintAll(wait bool) error

PrintAll will print all the remaining data. Passing true will make the printer wait for the user to press enter between each rows

type TabPrinterOption

type TabPrinterOption func(printer *TabPrinter)

TabPrinterOption lets you customize your TabPrinter instance

func WithSeparator

func WithSeparator(sep byte) TabPrinterOption

WithSeparator returns a TabPrinterOption to set the printer separator character

func WithTemplate

func WithTemplate(t string) TabPrinterOption

WithTemplate returns a TabPrinterOption to set the printer template

func WithWidth

func WithWidth(w int) TabPrinterOption

WithWidth returns a TabPrinterOption to set the printer width

type TemplatePrinter

type TemplatePrinter struct {
	Wait     bool
	Template string
	// contains filtered or unexported fields
}

TemplatePrinter prints data according to a template.

func NewTemplatePrinter

func NewTemplatePrinter(writer io.Writer, reader io.Reader, tpl string) *TemplatePrinter

NewTemplatePrinter returns a TemplatePrinter initialised with given options

func (*TemplatePrinter) Append

func (t *TemplatePrinter) Append(row interface{})

Append adds a row of data to the collection of data to print

func (*TemplatePrinter) BulkAppend

func (t *TemplatePrinter) BulkAppend(rows []interface{})

BulkAppend adds a serie of rows of data to the collection of data to print

func (*TemplatePrinter) PrintAll

func (t *TemplatePrinter) PrintAll(wait bool) error

PrintAll will print all the remaining data. Passing true will make the printer wait for the user to press enter between each rows

Jump to

Keyboard shortcuts

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