cmdutil

package
v0.15.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2018 License: Apache-2.0 Imports: 24 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 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're in an interactive terminal session.

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 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 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(color colors.Colorization)

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.

Jump to

Keyboard shortcuts

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