Documentation ¶
Index ¶
- Variables
- func ArgsFunc(argsValidator cobra.PositionalArgs) cobra.PositionalArgs
- func CloseProfiling(prefix string) error
- func CloseTracing()
- func DetailedError(err error) string
- func Diag() diag.Sink
- func EmojiOr(e, or string) string
- func EndKeypadTransmitMode()
- func ExactArgs(n int) cobra.PositionalArgs
- func Exit(err error)
- func ExitError(msg string)
- func GetGlobalColorization() colors.Colorization
- func InitDiag(opts diag.FormatOptions)
- func InitProfiling(prefix string) error
- func InitTracing(name, rootSpanName, tracingEndpoint string)
- func Interactive() bool
- func InteractiveTerminal() bool
- func IsTracingEnabled() bool
- func IsTruthy(s string) bool
- func KillChildren(pid int) error
- func MaximumNArgs(n int) cobra.PositionalArgs
- func MinimumNArgs(n int) cobra.PositionalArgs
- func PrintTable(table Table)
- func PrintTableWithGap(table Table, columnGap string)
- func RangeArgs(min int, max int) cobra.PositionalArgs
- func ReadConsole(prompt string) (string, error)
- func ReadConsoleNoEcho(prompt string) (string, error)
- func RegisterProcessGroup(cmd *exec.Cmd)
- func RemoveTrailingNewline(s string) string
- func RunFunc(run func(cmd *cobra.Command, args []string) error) func(*cobra.Command, []string)
- func RunResultFunc(run func(cmd *cobra.Command, args []string) result.Result) func(*cobra.Command, []string)
- func SetGlobalColorization(value string) error
- func SpecificArgs(argNames []string) cobra.PositionalArgs
- type Spinner
- type Table
- type TableRow
Constants ¶
This section is empty.
Variables ¶
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{ "⠋", "⠙", "⠚", "⠒", "⠂", "⠂", "⠒", "⠲", "⠴", "⠦", "⠖", "⠒", "⠐", "⠐", "⠒", "⠓", "⠋", } )
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.
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.
var NoArgs = ArgsFunc(cobra.NoArgs)
NoArgs is the same as cobra.NoArgs, except it is wrapped with ArgsFunc to provide standard Pulumi error handling.
var TracingEndpoint string
TracingEndpoint is the Zipkin-compatible tracing endpoint where tracing data will be sent.
var TracingRootSpan opentracing.Span
var TracingToFile bool
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 CloseTracing ¶
func CloseTracing()
CloseTracing ensures that all pending spans have been flushed. It should be called before process exit.
func DetailedError ¶
DetailedError extracts a detailed error message, including stack trace, if there is one.
func EmojiOr ¶
EmojiOr returns the emoji string e if emojis are enabled, or the string or if emojis are disabled.
func EndKeypadTransmitMode ¶
func EndKeypadTransmitMode()
EndKeypadTransmitMode switches the terminal out of the keypad transmit 'application' mode back to 'normal' mode.
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 ExitError ¶
func ExitError(msg string)
ExitError issues an error and exits with a standard error exit code.
func GetGlobalColorization ¶
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 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 ¶
func InteractiveTerminal() bool
InteractiveTerminal returns true if the current terminal session is interactive.
func IsTracingEnabled ¶
func IsTracingEnabled() bool
func IsTruthy ¶
IsTruthy returns true if the given string represents a CLI input interpreted as "true".
func KillChildren ¶
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 MinimumNArgs ¶
func MinimumNArgs(n int) cobra.PositionalArgs
MinimumNArgs is the same as cobra.MinimumNArgs, except it is wrapped with ArgsFunc to provide standard Pulumi error handling.
func PrintTable ¶
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 ¶
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 ¶
ReadConsole reads the console with the given prompt text.
func ReadConsoleNoEcho ¶
ReadConsoleNoEcho reads from the console without echoing. This is useful for reading passwords.
func RegisterProcessGroup ¶
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 RemoveTrailingNewline ¶
RemoveTrailingNewline 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 ¶
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 ¶
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 ¶
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.