cmdutil

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2019 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultASCIISpinFrames is the default set of symbols to show while spinning in an ASCII TTY setting.
	DefaultASCIISpinFrames = []string{
		"|", "/", "-", "\\",
	}
	// DefaultEmojiSpinFrames is the default set of symbols to show while spinning in a Unicode-enabled TTY setting.
	DefaultEmojiSpinFrames = []string{
		"⠋", "⠙", "⠚", "⠒", "⠂", "⠂", "⠒", "⠲", "⠴", "⠦", "⠖", "⠒", "⠐", "⠐", "⠒", "⠓", "⠋",
	}
)
View Source
var DisableInteractive bool

DisableInteractive may be set to true in order to disable prompts. This is useful when running in a non-attended scenario, such as in continuous integration, or when using the Pulumi CLI/SDK in a programmatic way.

View Source
var Emoji = (runtime.GOOS == "darwin")

Emoji controls whether emojis will by default be printed in the output. While some Linux systems can display Emoji's in the terminal by default, we restrict this to just macOS, like Yarn.

NoArgs is the same as cobra.NoArgs, except it is wrapped with ArgsFunc to provide standard Pulumi error handling.

View Source
var TracingEndpoint string

TracingEndpoint is the Zipkin-compatible tracing endpoint where tracing data will be sent.

View Source
var TracingRootSpan opentracing.Span

Functions

func ArgsFunc

func ArgsFunc(argsValidator cobra.PositionalArgs) cobra.PositionalArgs

ArgsFunc wraps a standard cobra argument validator with standard Pulumi error handling.

func CloseProfiling

func CloseProfiling(prefix string) error

func CloseTracing

func CloseTracing()

CloseTracing ensures that all pending spans have been flushed. It should be called before process exit.

func DetailedError

func DetailedError(err error) string

DetailedError extracts a detailed error message, including stack trace, if there is one.

func Diag

func Diag() diag.Sink

Diag lazily allocates a sink to be used if we can't create a compiler.

func EmojiOr

func EmojiOr(e, or string) string

EmojiOr returns the emoji string e if emojis are enabled, or the string or if emojis are disabled.

func ExactArgs

func ExactArgs(n int) cobra.PositionalArgs

ExactArgs is the same as cobra.ExactArgs, except it is wrapped with ArgsFunc to provide standard Pulumi error handling.

func Exit

func Exit(err error)

Exit exits with a given error.

func ExitError

func ExitError(msg string, args ...interface{})

ExitError issues an error and exits with a standard error exit code.

func GetGlobalColorization added in v0.14.3

func GetGlobalColorization() colors.Colorization

GetGlobalColorization gets the global setting for how things should be colored. This is helpful for the parts of our stack that do not take a DisplayOptions struct.

func InitDiag

func InitDiag(opts diag.FormatOptions)

InitDiag forces initialization of the diagnostics sink with the given options.

func InitProfiling

func InitProfiling(prefix string) error

func InitTracing

func InitTracing(name, rootSpanName, tracingEndpoint string)

InitTracing initializes tracing

func Interactive

func Interactive() bool

Interactive returns true if we should be running in interactive mode. That is, we have an interactive terminal session, interactivity hasn't been explicitly disabled, and we're not running in a known CI system.

func InteractiveTerminal added in v0.16.0

func InteractiveTerminal() bool

InteractiveTerminal returns true if the current terminal session is interactive.

func IsTracingEnabled

func IsTracingEnabled() bool

func IsTruthy

func IsTruthy(s string) bool

IsTruthy returns true if the given string represents a CLI input interpreted as "true".

func KillChildren

func KillChildren(pid int) error

KillChildren calls os.Process.Kill() on every child process of `pid`'s, stoping after the first error (if any). It also only kills direct child process, not any children they may have.

func MaximumNArgs

func MaximumNArgs(n int) cobra.PositionalArgs

MaximumNArgs is the same as cobra.MaximumNArgs, except it is wrapped with ArgsFunc to provide standard Pulumi error handling.

func PrintTable added in v0.16.7

func PrintTable(table Table)

PrintTable prints a grid of rows and columns. Width of columns is automatically determined by the max length of the items in each column. A default gap of two spaces is printed between each column.

func PrintTableWithGap added in v0.16.7

func PrintTableWithGap(table Table, columnGap string)

PrintTableWithGap prints a grid of rows and columns. Width of columns is automatically determined by the max length of the items in each column. A gap can be specified between the columns.

func RangeArgs

func RangeArgs(min int, max int) cobra.PositionalArgs

RangeArgs is the same as cobra.RangeArgs, except it is wrapped with ArgsFunc to provide standard Pulumi error handling.

func ReadConsole

func ReadConsole(prompt string) (string, error)

ReadConsole reads the console with the given prompt text.

func ReadConsoleNoEcho

func ReadConsoleNoEcho(prompt string) (string, error)

ReadConsoleNoEcho reads from the console without echoing. This is useful for reading passwords.

func RegisterProcessGroup

func RegisterProcessGroup(cmd *exec.Cmd)

RegisterProcessGroup informs the OS that it needs to call `setpgid` on this child process. When it comes time to kill this process, we'll kill all processes in the same process group.

func RemoveTralingNewline

func RemoveTralingNewline(s string) string

RemoveTralingNewline removes a trailing newline from a string. On windows, we'll remove either \r\n or \n, on other platforms, we just remove \n.

func RunFunc

func RunFunc(run func(cmd *cobra.Command, args []string) error) func(*cobra.Command, []string)

RunFunc wraps an error-returning run func with standard Pulumi error handling. All Pulumi commands should wrap themselves in this or RunResultFunc to ensure consistent and appropriate error behavior. In particular, we want to avoid any calls to os.Exit in the middle of a callstack which might prohibit reaping of child processes, resources, etc. And we wish to avoid the default Cobra unhandled error behavior, because it is formatted incorrectly and needlessly prints usage.

func RunResultFunc added in v0.17.2

func RunResultFunc(run func(cmd *cobra.Command, args []string) *result.Result) func(*cobra.Command, []string)

RunResultFunc wraps an Result-returning run func with standard Pulumi error handling. All Pulumi commands should wrap themselves in this or RunFunc to ensure consistent and appropriate error behavior. In particular, we want to avoid any calls to os.Exit in the middle of a callstack which might prohibit reaping of child processes, resources, etc. And we wish to avoid the default Cobra unhandled error behavior, because it is formatted incorrectly and needlessly prints usage.

func SetGlobalColorization added in v0.14.3

func SetGlobalColorization(value string) error

SetGlobalColorization sets the global setting for how things should be colored. This is helpful for the parts of our stack that do not take a DisplayOptions struct.

func SpecificArgs

func SpecificArgs(argNames []string) cobra.PositionalArgs

SpecificArgs requires a set of specific arguments. We use the names to improve diagnostics.

Types

type Spinner

type Spinner interface {
	// Print the next frame of the spinner. After Tick() has been called, there should be no writes to Stdout before
	// calling Reset().
	Tick()

	// Called to release ownership of stdout, so others may write to it.
	Reset()
}

Spinner represents a very simple progress reporter.

func NewSpinnerAndTicker

func NewSpinnerAndTicker(prefix string, ttyFrames []string, timesPerSecond time.Duration) (Spinner, *time.Ticker)

NewSpinnerAndTicker returns a new Spinner and a ticker that will fire an event when the next call to Spinner.Tick() should be called. NewSpinnerAndTicket takes into account if stdout is connected to a tty or not and returns either a nice animated spinner that updates quickly, using the specified ttyFrames, or a simple spinner that just prints a dot on each tick and updates slowly.

type Table added in v0.16.7

type Table struct {
	Headers []string
	Rows    []TableRow // Rows of the table.
	Prefix  string     // Optional prefix to print before each row
}

type TableRow added in v0.16.7

type TableRow struct {
	Columns        []string // Columns of the row
	AdditionalInfo string   // an optional line of information to print after the row
}

TableRow is a row in a table we want to print. It can be a series of a columns, followed by an additional line of information.

Jump to

Keyboard shortcuts

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