Documentation
¶
Index ¶
- Variables
- func AddJSONFlags(cmd *cobra.Command, exportTarget *Exporter, fields []string)
- func CheckAuth(cfg config.Config) bool
- func DisableAuthCheck(cmd *cobra.Command)
- func FlagErrorWrap(err error) error
- func FlagErrorf(format string, args ...interface{}) error
- func HostnameValidator(v interface{}) error
- func IsAuthCheckEnabled(cmd *cobra.Command) bool
- func IsCygwinTerminal(f *os.File) bool
- func IsUserCancellation(err error) bool
- func MutuallyExclusive(message string, conditions ...bool) error
- func ReadFile(filename string, stdin io.ReadCloser) ([]byte, error)
- type Exporter
- type FlagError
- type JSONFlagError
- type TablePrinter
- type TablePrinterOptions
Constants ¶
This section is empty.
Variables ¶
var ErrCancel = errors.New("CancelError")
ErrCancel signals user-initiated cancellation.
var ErrSilent = errors.New("SilentError")
ErrSilent is an error that triggers exit code 1 without any error messaging.
var IsTerminal = func(f *os.File) bool { return isatty.IsTerminal(f.Fd()) || IsCygwinTerminal(f) }
IsTerminal returns true if the given file descriptor is a terminal.
var TerminalSize = func(w interface{}) (int, int, error) { if f, isFile := w.(*os.File); isFile { return term.GetSize(int(f.Fd())) } return 0, 0, fmt.Errorf("%v is not a file", w) }
TerminalSize returns the height and width in characters of the given terminal.
Functions ¶
func AddJSONFlags ¶
AddJSONFlags adds JSON output flags to a command.
func DisableAuthCheck ¶
DisableAuthCheck disables the auth check for the given command.
func FlagErrorWrap ¶
FlagErrorWrap returns a new FlagError that wraps the specified error.
func FlagErrorf ¶
FlagErrorf returns a new FlagError that wraps an error produced by fmt.Errorf(format, args...).
func HostnameValidator ¶
func HostnameValidator(v interface{}) error
HostnameValidator is a function that validates a hostname.
func IsAuthCheckEnabled ¶
IsAuthCheckEnabled checks if the auth check is enabled for the given command.
func IsCygwinTerminal ¶
IsCygwinTerminal returns true if the given file descriptor is a Cygwin terminal.
func IsUserCancellation ¶
IsUserCancellation returns true if the user cancelled the operation.
func MutuallyExclusive ¶
MutuallyExclusive sets of flags that are mutually exclusive.
Types ¶
type Exporter ¶
type Exporter interface { Fields() []string Write(io *iostreams.IOStreams, data interface{}) error }
Exporter is a function that can be used to export data to a writer.
type FlagError ¶
type FlagError struct {
// contains filtered or unexported fields
}
FlagError indicates an error processing command-line flags or other arguments. Such errors cause the application to display the usage message.
type JSONFlagError ¶
type JSONFlagError struct {
// contains filtered or unexported fields
}
JSONFlagError is returned by AddJSONFlags when the user specifies an invalid JSON field.
type TablePrinter ¶
type TablePrinter interface { IsTTY() bool AddField(string, func(int, string) string, func(string) string) EndRow() Render() error }
TablePrinter is an interface for printing tabular data.
func NewTablePrinter ¶
func NewTablePrinter(io *iostreams.IOStreams) TablePrinter
NewTablePrinter returns a TablePrinter that prints to the given io.Writer.
func NewTablePrinterWithOptions ¶
func NewTablePrinterWithOptions(io *iostreams.IOStreams, opts TablePrinterOptions) TablePrinter
NewTablePrinterWithOptions returns a TablePrinter that prints to the given io.Writer.
type TablePrinterOptions ¶
type TablePrinterOptions struct {
IsTTY bool
}
TablePrinterOptions are options for configuring a TablePrinter.