cmd

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2019 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OnlyUsageString = "{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}"
	ADocHelpTable   = `{{if .HasAvailableLocalFlags}}{{ $tick := "` + "`" + `" }}
[cols="2,4,2,1"]
|===
|Option|Purpose|Format|Default
{{range localFlagsSlice .LocalFlags}}{{ if not .Hidden }}
|{{$tick}}--{{.Name}}{{$tick}} {{if .Shorthand}}({{$tick}}-{{.Shorthand}}{{$tick}}){{end}}
|{{.Usage}}
|{{type .}}
|{{if .DefValue}}{{$tick}}{{.DefValue | trimTrailingWhitespaces}}{{$tick}}{{end}}{{end}}
{{end}}
|===
{{end}}`
)

Variables

View Source
var BufferAndStreamOutput = gocmd.Options{
	Buffered:  true,
	Streaming: true,
}

BufferAndStreamOutput sets buffering and streaming of output when running gocmd.Cmd Buffering lets easy inspection of outputs in tests through inspecting gocmd.Cmd.Status.Stdout/err slices

View Source
var StreamOutput = gocmd.Options{
	Buffered:  false,
	Streaming: true,
}

StreamOutput sets streaming of output instead of buffering it when running gocmd.Cmd

Functions

func BinaryExists

func BinaryExists(binName, hint string) bool

BinaryExists ensures that binary with given name (binName) is available on the PATH hint lets you customize the error message

func CurrentDir

func CurrentDir() string

CurrentDir returns current directory from where binary is executed

func EnhanceHelper

func EnhanceHelper(command *cobra.Command)

EnhanceHelper wraps helper function with alternative formatting and templates (e.g. asciidoc) based on --helper-format flag Applies to all subcommands. This can be useful when automatically generating documentation for CLI

func Execute

func Execute(command string) *gocmd.Cmd

Execute executes given command in the current directory Adds shutdown hook and redirects streams to stdout/err

func ExecuteInDir

func ExecuteInDir(dir, name string, args ...string) *gocmd.Cmd

ExecuteInDir executes given command in the defined directory Adds shutdown hook and redirects streams to stdout/err

func NewDevelopCmd

func NewDevelopCmd() *cobra.Command

NewDevelopCmd creates instance of "develop" Cobra Command with flags and execution logic defined

func NewInstallCmd

func NewInstallCmd() *cobra.Command

NewInstallCmd takes care of deploying server-side components of istio-workspace

func NewRootCmd

func NewRootCmd() *cobra.Command

NewRootCmd creates instance of root "ike" Cobra Command with flags and execution logic defined

func NewServeCmd

func NewServeCmd() *cobra.Command

NewServeCmd creates instance of "ike serve" Cobra Command which is intended to be ran in the cluster as it starts istio-workspace operator

func NewVersionCmd

func NewVersionCmd() *cobra.Command

NewVersionCmd creates version cmd which prints version and build details of the executed binary

func NewWatchCmd

func NewWatchCmd() *cobra.Command

NewWatchCmd creates watch command which observes file system changes in the defined set of directories and re-runs build and run command when they occur. It is hidden (not user facing) as it's integral part of develop command

func RedirectStreams

func RedirectStreams(src *gocmd.Cmd, stdoutDest, stderrDest io.Writer, done <-chan gocmd.Status)

RedirectStreams redirects Stdout and Stderr of the gocmd.Cmd process to passed io.Writers

func ShutdownHook

func ShutdownHook(cmd *gocmd.Cmd, done <-chan gocmd.Status)

ShutdownHook will wait for SIGTERM signal and stop the cmd unless done receiving channel passed to it receives status or is closed

func Start

func Start(cmd *gocmd.Cmd, done chan gocmd.Status)

Start starts new process (gocmd) and wait until it's done. Status struct is then propagated back to done channel passed as argument

func ToOptions

func ToOptions(flags *pflag.FlagSet) (session.Options, error)

ToOptions converts between FlagSet to a Handler Options

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳