console

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func ProgressReader(reader io.Reader, operation string, length int64) io.Reader

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

type TargetDevice interface {
	Identifier() string
	FriendlyName() string
	Size() uint64
}

TargetDevice represents target.Device.

Jump to

Keyboard shortcuts

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