Documentation ¶
Overview ¶
flag_helpers.go are private functions from pflag/flag.go
Package xmain provides a standard stub for the main of a command handling logging, flags, signals and shutdown.
Index ¶
- func Main(run RunFunc)
- type ExitError
- type Opts
- func (o *Opts) Bool(envKey, flag, shortFlag string, defaultVal bool, usage string) (*bool, error)
- func (o *Opts) Defaults() string
- func (o *Opts) Float64(envKey, flag, shortFlag string, defaultVal float64, usage string) (*float64, error)
- func (o *Opts) Int64(envKey, flag, shortFlag string, defaultVal int64, usage string) (*int64, error)
- func (o *Opts) Int64Slice(envKey, flag, shortFlag string, defaultVal []int64, usage string) (*[]int64, error)
- func (o *Opts) String(envKey, flag, shortFlag string, defaultVal, usage string) *string
- type RunFunc
- type State
- type TestState
- func (ts *TestState) Cleanup(tb testing.TB)
- func (ts *TestState) Signal(ctx context.Context, sig os.Signal) (err error)
- func (ts *TestState) Start(tb testing.TB, ctx context.Context)
- func (ts *TestState) StderrPipe() (pr io.Reader)
- func (ts *TestState) StdinPipe() (pw io.WriteCloser)
- func (ts *TestState) StdoutPipe() (pr io.Reader)
- func (ts *TestState) Wait(ctx context.Context) (err error)
- type UsageError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ExitError ¶
func ExitErrorf ¶
type Opts ¶
func (*Opts) Defaults ¶
Mostly copy pasted pasted from pflag.FlagUsagesWrapped with modifications for env var
func (*Opts) Int64Slice ¶
type State ¶
type State struct { Name string Stdin io.Reader Stdout io.WriteCloser Stderr io.WriteCloser Log *cmdlog.Logger Env *xos.Env Opts *Opts PWD string }
func (*State) HumanPath ¶
HumanPath makes absolute path fp more suitable for human consumption by replacing $HOME in fp with ~ and making it relative to the current PWD.
type TestState ¶
type TestState struct { Run func(context.Context, *State) error Env *xos.Env Args []string PWD string Stdin io.Reader Stdout io.Writer Stderr io.Writer // contains filtered or unexported fields }
func (*TestState) StderrPipe ¶
func (*TestState) StdinPipe ¶
func (ts *TestState) StdinPipe() (pw io.WriteCloser)
func (*TestState) StdoutPipe ¶
type UsageError ¶
type UsageError struct {
Message string `json:"message"`
}
func UsageErrorf ¶
func UsageErrorf(msg string, v ...interface{}) UsageError
func (UsageError) Error ¶
func (ue UsageError) Error() string
Click to show internal directories.
Click to hide internal directories.