func Main(run RunFunc)
type ExitError struct { Code int `json:"code"` Message string `json:"message"` }
func ExitErrorf(code int, msg string, v ...interface{}) ExitError
func (ee ExitError) Error() string
type Opts struct { Args []string Flags *pflag.FlagSet // contains filtered or unexported fields }
func NewOpts(env *xos.Env, args []string) *Opts
func (o *Opts) Bool(envKey, flag, shortFlag string, defaultVal bool, usage string) (*bool, error)
func (o *Opts) Defaults() string
Mostly copy pasted pasted from pflag.FlagUsagesWrapped with modifications for env var
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 func(context.Context, *State) error
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 (ms *State) AbsPath(fp string) string
AbsPath joins the PWD with fp to give the absolute path to fp.
func (ms *State) HumanPath(fp string) string
HumanPath makes absolute path fp more suitable for human consumption by replacing $HOME in fp with ~ and making it relative to the current PWD.
func (ms *State) Main(ctx context.Context, sigs <-chan os.Signal, run func(context.Context, *State) error) error
func (ms *State) ReadPath(fp string) ([]byte, error)
func (ms *State) WritePath(fp string, p []byte) error
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 (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 struct { Message string `json:"message"` }
func UsageErrorf(msg string, v ...interface{}) UsageError
func (ue UsageError) Error() string