Documentation
¶
Index ¶
- Variables
- type Router
- func (r *Router) Group(name, desc string, closure func())
- func (r *Router) Handle(handler any)
- func (r *Router) HandleGroup(name, desc string, handler any)
- func (r *Router) Parsed(pointer any) bool
- func (r *Router) Run(ctx context.Context, args ...string) (string, error)
- func (r *Router) RunCmdline(ctx context.Context)
- func (r *Router) Stmt(closure func())
- func (r *Router) Use(middlewares ...any)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoExecFunc = flags.ErrNoExecFunc ErrNoInputValue = flags.ErrNoInputValue ErrHelp = flags.ErrHelp )
Functions ¶
This section is empty.
Types ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Handle ¶
handler must be one of following format:
- `func()`
- `func(context.Context)`
- `func(arg)` or `func(*arg)`
- `func(context.Context, arg)` or `func(context.Context, *arg)`
and arg must be like:
struct {
A int `short:"a" long:"all" dft:"123" desc:"what is a"`
}
func (*Router) HandleGroup ¶
handler must be one of following format:
- `func()`
- `func(context.Context)`
- `func(arg)` or `func(*arg)`
- `func(context.Context, arg)` or `func(context.Context, *arg)`
and arg must be like:
struct {
A int `short:"a" long:"all" dft:"123" desc:"what is a"`
}
func (*Router) RunCmdline ¶
RunCmdline parse os.args and exec the subcommand.
func (*Router) Stmt ¶
func (r *Router) Stmt(closure func())
Stmt open a new empty statement, use closure to register subcommands. It is always used to register some middlewares those not influence other cmds.
func (*Router) Use ¶
middleware must be one of following format:
- `func()`
- `func(context.Context)`
- `func(arg)` or `func(*arg)`
- `func(handler func())`
- `func(context.Context, arg)` or `func(context.Context, *arg)`
- `func(arg, handler func())` or `func(*arg, handler func())`
- `func(context.Context, handler func())` or `func(context.Context, handler func(context.Context))`
- `func(context.Context, arg, handler func())` or `func(context.Context, *arg, handler func())`
- `func(context.Context, arg, handler func(context.Context))` or `func(context.Context, *arg, handler func(context.Context))`
and arg must be like:
struct {
A int `short:"a" long:"all" dft:"123" desc:"what is a"`
}
Click to show internal directories.
Click to hide internal directories.