ioutils

package
v0.0.0-...-f99bb4a Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AssumeYes bool

AssumeYes automatically answers yes for all questions.

Functions

This section is empty.

Types

type ConfirmationMessage

type ConfirmationMessage string

func WithDangerZoneMessagef

func WithDangerZoneMessagef(consequence, action string, args ...interface{}) ConfirmationMessage

func WithMessagef

func WithMessagef(action string, args ...interface{}) ConfirmationMessage

type DefaultTerminal

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

DefaultTerminal a wrapper around a Cobra command, with extra methods to display messages.

func (*DefaultTerminal) AskForConfirmation

func (t *DefaultTerminal) AskForConfirmation(msg ConfirmationMessage) bool

func (*DefaultTerminal) InOrStdin

func (t *DefaultTerminal) InOrStdin() io.Reader

InOrStdin returns an `io.Reader` to read the user's input

func (*DefaultTerminal) OutOrStdout

func (t *DefaultTerminal) OutOrStdout() io.Writer

OutOrStdout returns an `io.Writer` to write messages in the console

func (*DefaultTerminal) PrintContextSeparatorWithBodyf

func (t *DefaultTerminal) PrintContextSeparatorWithBodyf(body, context string, args ...interface{})

PrintContextSeparatorWithBodyf prints the context separator and a message

func (*DefaultTerminal) PrintContextSeparatorf

func (t *DefaultTerminal) PrintContextSeparatorf(context string, args ...interface{})

PrintContextSeparatorf prints the context separator (only)

func (*DefaultTerminal) PrintObject

func (t *DefaultTerminal) PrintObject(object runtime.Object, title string) error

PrintObject prints the given object

func (*DefaultTerminal) Printf

func (t *DefaultTerminal) Printf(format string, args ...interface{})

Printf prints the given message with arguments

func (*DefaultTerminal) Println

func (t *DefaultTerminal) Println(msg string)

Println prints the given message and appends a line feed

func (*DefaultTerminal) Printlnf

func (t *DefaultTerminal) Printlnf(format string, args ...interface{})

Printlnf prints the given message with arguments and appends a line feed

type Terminal

type Terminal interface {
	InOrStdin() io.Reader
	OutOrStdout() io.Writer
	AskForConfirmation(msg ConfirmationMessage) bool
	Println(msg string)
	Printlnf(msg string, args ...interface{})
	PrintContextSeparatorf(context string, args ...interface{})
	PrintContextSeparatorWithBodyf(body, context string, args ...interface{})
	PrintObject(object runtime.Object, title string) error
}

Terminal a wrapper around a Cobra command, with extra methods to display messages.

func NewTerminal

func NewTerminal(in func() io.Reader, out func() io.Writer) Terminal

NewTerminal returns a new terminal with the given funcs to access the `in` reader and `out` writer

Jump to

Keyboard shortcuts

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