cmd

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const GlobalFlags = "global"
View Source
const IgnoreError = -1
View Source
const JwtParam = "jwt"
View Source
const StatusParam = "status_code"

Variables

This section is empty.

Functions

func RegisterCommand

func RegisterCommand(name string, c Command)

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) Execute

func (c *CmdBase) Execute() error

func (*CmdBase) GetBase

func (c *CmdBase) GetBase() *CmdBase

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

func GetCommand(name string) (Command, error)

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) Exec

func (e *Environment) Exec(m *parser.Method, i *common.Input) error

func (*Environment) Wait

func (e *Environment) Wait() error

type GlobalResult

type GlobalResult struct {
	Count       uint
	RetryCount  int64
	BasePath    string
	Scheme      string
	Server      string
	Doc         string
	Format      string
	Verbose     bool
	Parallel    bool
	IgnoreError bool
}

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

func New(o *parser.Method, in *common.Input, r *parser.Root) *ParseResult

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL