Documentation
¶
Index ¶
Constants ¶
const GlobalFlags = "global"
const IgnoreError = -1
const JwtParam = "jwt"
const StatusParam = "status_code"
Variables ¶
This section is empty.
Functions ¶
func RegisterCommand ¶
RegisterCommand registers a Command implementation under the given extension class name (the value returned by Method.GetExtensionClass(), which maps to the "class" field of an operation's extension in the OpenAPI spec).
This lets a program that imports tcli as a library add its own command types (e.g. for publishing to a queue or topic) without needing to copy source files into this package. Call it from an init() in your own package, then blank-import that package from your main so the init() runs:
package mypubsub
func init() {
cmd.RegisterCommand("sqs", &SqsCommand{})
}
// in your main package
import _ "example.com/myclient/mypubsub"
Types ¶
type CmdBase ¶
type CmdBase struct {
// contains filtered or unexported fields
}
func (*CmdBase) Global ¶
func (c *CmdBase) Global() *GlobalResult
Global returns the parsed global flag values for this command.
func (*CmdBase) InitBase ¶
func (c *CmdBase) InitBase(p *ParseResult, f func() error)
InitBase initializes a CmdBase from outside this package. Custom Command implementations registered via RegisterCommand should call this from their Init method instead of reimplementing CmdBase's plumbing:
func (c *MyCommand) Init(p *cmd.ParseResult) cmd.Command {
k := MyCommand{}
k.InitBase(p, k.run)
return &k
}
func (*CmdBase) Params ¶
func (c *CmdBase) Params() *ParseResult
Params returns the parsed parameter values for this command, so external Command implementations can read parameters without needing direct access to CmdBase's unexported fields.
type Command ¶
type Command interface {
Init(*ParseResult) Command
Execute() error
GetBase() *CmdBase
}
func GetCommand ¶
type EchoCommand ¶
type EchoCommand struct {
CmdBase
}
func (*EchoCommand) Init ¶
func (c *EchoCommand) Init(p *ParseResult) Command
type Environment ¶
type Environment struct {
Args []string
Parallel *ParallelEnvironment
}
func GetExecutionEnv ¶
func GetExecutionEnv(args []string) *Environment
func (*Environment) Wait ¶
func (e *Environment) Wait() error
type GlobalResult ¶
type HttpCommand ¶
type HttpCommand struct {
CmdBase
}
func (*HttpCommand) Init ¶
func (c *HttpCommand) Init(p *ParseResult) Command
type ParallelEnvironment ¶
type ParallelEnvironment struct {
// contains filtered or unexported fields
}
type ParseResult ¶
type ParseResult struct {
Path string
Flags *flag.FlagSet
Values common.Values
Method *parser.Method
Global *GlobalResult
}
func New ¶
New creates a new ParseResult and initializes the flag set with the parameters from the given method and global flags.
func (*ParseResult) ValidateParams ¶
func (p *ParseResult) ValidateParams() error
ValidateParams checks that all required parameters have values and sets global configuration options based on the parsed values.
type TcpCommand ¶
type TcpCommand struct {
CmdBase
}
func (*TcpCommand) Init ¶
func (c *TcpCommand) Init(p *ParseResult) Command