Versions in this module Expand all Collapse all v0 v0.0.1 Jun 20, 2021 Changes in this version + const Bool + const CLI + const ChanOpt + const DefaultOutputEncoding + const DerefLong + const EncLong + const EncShort + const Float + const Hidden + const HiddenShort + const Ignore + const IgnoreRules + const Int + const Int64 + const Invalid + const JSON + const OptLongHelp + const OptShortHelp + const Protobuf + const RecLong + const RecShort + const StdinName + const String + const Strings + const Text + const TextNewline + const TimeoutOpt + const Uint + const Uint64 + const Undefined + const XML + var Decoders = map[EncodingType]func(w io.Reader) Decoder + var Encoders = EncoderMap + var ErrClosedEmitter = errors.New("cmds: emit on closed emitter") + var ErrClosingClosedEmitter = errors.New("cmds: closing closed emitter") + var ErrIncorrectType = errors.New("the command returned a value with a different type than expected") + var ErrNoFormatter = ClientError("this command cannot be formatted to plain text") + var ErrNotCallable = ClientError("this command cannot be called directly; try one of its subcommands.") + var OptionDerefArgs = BoolOption(DerefLong, "Symlinks supplied in arguments are dereferenced") + var OptionEncodingType = StringOption(EncLong, EncShort, "The encoding type the output should be encoded with (json, xml, or text)").WithDefault("text") + var OptionHidden = BoolOption(Hidden, HiddenShort, ...) + var OptionIgnore = StringsOption(Ignore, ...) + var OptionIgnoreRules = StringOption(IgnoreRules, ...) + var OptionRecursivePath = BoolOption(RecLong, RecShort, "Add directory paths recursively") + var OptionStdinName = StringOption(StdinName, "Assign a name if the file source is stdin.") + var OptionStreamChannels = BoolOption(ChanOpt, "Stream channel output") + var OptionTimeout = StringOption(TimeoutOpt, "Set a global timeout on the command") + func ClientError(msg string) error + func Copy(re ResponseEmitter, res Response) error + func EmitChan(re ResponseEmitter, ch <-chan interface{}) error + func EmitOnce(re ResponseEmitter, v interface{}) error + func GetEncoder(req *Request, w io.Writer, def EncodingType) (encType EncodingType, enc Encoder, err error) + func MakeEncoder(f func(*Request, io.Writer, interface{}) error) func(*Request) func(io.Writer) Encoder + func MakeTypedEncoder(f interface{}) func(*Request) func(io.Writer) Encoder + func NewChanResponsePair(req *Request) (ResponseEmitter, Response) + type Argument struct + Description string + Name string + Recursive bool + Required bool + SupportsStdin bool + Type ArgumentType + Variadic bool + func FileArg(name string, required, variadic bool, description string) Argument + func StringArg(name string, required, variadic bool, description string) Argument + func (a Argument) EnableRecursive() Argument + func (a Argument) EnableStdin() Argument + type ArgumentType int + const ArgFile + const ArgString + type Command struct + Arguments []Argument + Encoders EncoderMap + External bool + Extra *Extra + Helptext HelpText + NoLocal bool + NoRemote bool + Options []Option + PostRun PostRunMap + PreRun func(req *Request, env Environment) error + Run Function + Subcommands map[string]*Command + Type interface{} + func (c *Command) Call(req *Request, re ResponseEmitter, env Environment) + func (c *Command) CheckArguments(req *Request) error + func (c *Command) DebugValidate() map[string][]error + func (c *Command) Get(path []string) (*Command, error) + func (c *Command) GetOptions(path []string) (map[string]Option, error) + func (c *Command) ProcessHelp() + func (c *Command) Resolve(pth []string) ([]*Command, error) + func (c *Command) Walk(visitor CommandVisitor) + type CommandVisitor func(*Command) + type Decoder interface + Decode func(value interface{}) error + type Encoder interface + Encode func(value interface{}) error + type EncoderFunc func(req *Request) func(w io.Writer) Encoder + type EncoderMap map[EncodingType]EncoderFunc + type EncodingType string + func GetEncoding(req *Request, def EncodingType) EncodingType + type Environment interface + type Error struct + Code ErrorType + Message string + func Errorf(code ErrorType, format string, args ...interface{}) Error + func (e *Error) UnmarshalJSON(data []byte) error + func (e Error) Error() string + func (e Error) MarshalJSON() ([]byte, error) + func (e Error) Unwrap() error + type ErrorType uint + const ErrClient + const ErrForbidden + const ErrImplementation + const ErrNormal + const ErrRateLimited + func (e ErrorType) Error() string + func (e ErrorType) String() string + type Executor interface + Execute func(req *Request, re ResponseEmitter, env Environment) error + func NewExecutor(root *Command) Executor + type Extra struct + func (e *Extra) GetValue(key interface{}) (interface{}, bool) + func (e *Extra) SetValue(key, value interface{}) *Extra + type Flusher interface + Flush func() error + type Function func(*Request, ResponseEmitter, Environment) error + type HelpText struct + Arguments string + LongDescription string + Options string + ShortDescription string + Subcommands string + Synopsis string + SynopsisOptionsValues map[string]string + Tagline string + Usage string + type MakeEnvironment func(context.Context, *Request) (Environment, error) + type MakeExecutor func(*Request, interface{}) (Executor, error) + type MaybeError struct + Error *Error + Value interface{} + func (m *MaybeError) Get() (interface{}, error) + func (m *MaybeError) UnmarshalJSON(data []byte) error + type OptMap map[string]interface + type Option interface + Default func() interface{} + Description func() string + Name func() string + Names func() []string + Parse func(str string) (interface{}, error) + Type func() reflect.Kind + WithDefault func(interface{}) Option + func BoolOption(names ...string) Option + func DelimitedStringsOption(delimiter string, names ...string) Option + func FloatOption(names ...string) Option + func Int64Option(names ...string) Option + func IntOption(names ...string) Option + func NewOption(kind reflect.Kind, names ...string) Option + func StringOption(names ...string) Option + func StringsOption(names ...string) Option + func Uint64Option(names ...string) Option + func UintOption(names ...string) Option + type PostRunMap map[PostRunType]func(Response, ResponseEmitter) error + type PostRunType string + type ReqLog struct + Requests []*ReqLogEntry + func (rl *ReqLog) Add(req *Request) *ReqLogEntry + func (rl *ReqLog) AddEntry(rle *ReqLogEntry) + func (rl *ReqLog) ClearInactive() + func (rl *ReqLog) Finish(rle *ReqLogEntry) + func (rl *ReqLog) Report() []*ReqLogEntry + func (rl *ReqLog) SetKeepTime(t time.Duration) + type ReqLogEntry struct + Active bool + Args []string + Command string + EndTime time.Time + ID int + Options map[string]interface{} + StartTime time.Time + func (r *ReqLogEntry) Copy() *ReqLogEntry + type Request struct + Arguments []string + Command *Command + Context context.Context + Files files.Directory + Options OptMap + Path []string + Root *Command + func NewRequest(ctx context.Context, path []string, opts OptMap, args []string, ...) (*Request, error) + func (req *Request) BodyArgs() StdinArguments + func (req *Request) FillDefaults() error + func (req *Request) ParseBodyArgs() error + func (req *Request) SetOption(name string, value interface{}) + type Response interface + Error func() *Error + Length func() uint64 + Next func() (interface{}, error) + Request func() *Request + func NewReaderResponse(r io.Reader, req *Request) (Response, error) + type ResponseEmitter interface + Close func() error + CloseWithError func(error) error + Emit func(value interface{}) error + SetLength func(length uint64) + func NewFlushForwarder(re ResponseEmitter, f Flusher) ResponseEmitter + func NewWriterResponseEmitter(w io.WriteCloser, req *Request) (ResponseEmitter, error) + type Single struct + Value interface{} + func (s Single) GoString() string + func (s Single) String() string + type StdinArguments interface + Argument func() string + Err func() error + Scan func() bool + type TextEncoder struct + func (e TextEncoder) Encode(v interface{}) error