Documentation ¶
Overview ¶
Package console provides simple utilities to print human-readable messages to the console. For specific message types, additional verbosity is available through Verbose.
Index ¶
- Variables
- func Print(v ...interface{})
- func PrintDevices(targets []TargetDevice, w io.Writer, json bool)
- func Printf(format string, v ...interface{})
- func Printjson(targets []TargetDevice, w io.Writer) error
- func ProgressReader(reader io.Reader, operation string, length int64) io.Reader
- func PromptUser() error
- type TargetDevice
Constants ¶
This section is empty.
Variables ¶
var ( // Verbose is used to control whether or not print messages are printed. // It is exposed as package state to allow the verbosity to be uniformly // controlled across packages that use it. Verbose = false )
Functions ¶
func Print ¶
func Print(v ...interface{})
Print displays a console message when Verbose is false. Arguments are handled in the same manner as fmt.Print.
func PrintDevices ¶
func PrintDevices(targets []TargetDevice, w io.Writer, json bool)
PrintDevices takes a slice of target devices and prints relevant information as a human-readable table to the console. If the json flag is present the target devices will be printed as JSON rather than a table.
func Printf ¶
func Printf(format string, v ...interface{})
Printf displays a console message when Verbose is false. Arguments are handled in the same manner as fmt.Printf.
func Printjson ¶
func Printjson(targets []TargetDevice, w io.Writer) error
Printjson takes a slice of target devices and prints relevant information as JSON to the console when the json flag is present on the PrintDevices function.
func ProgressReader ¶
ProgressReader wraps an io.Reader and writes the read progress to the console. The writes are displayed on call of the Read method and at most every 5 seconds. The messages include the supplied human readable operation. The provided length can also be zero if it is unknown ahead of time. A ProgressReader always outputs to the console, regardless of the value of verbose.
func PromptUser ¶
func PromptUser() error
PromptUser displays a warning that the actions to be performed are destructive. It returns an error if the user does not respond with a 'y'. It is always printed, regardless of the value of Verbose.
Types ¶
type TargetDevice ¶
TargetDevice represents target.Device.