Documentation
¶
Index ¶
- Constants
- func FormatRoute(name, parent string) string
- type FlagType
- type Ktrl
- func (k *Ktrl) AddCommand(kcmd *KtrlCommand)
- func (k *Ktrl) GetResult(ctx *KtrlContext)
- func (k *Ktrl) GetShell() (sh *shell.IShell)
- func (k *Ktrl) PreServerStart()
- func (k *Ktrl) PreShellStart()
- func (k *Ktrl) SendMsg(name, parent string, options []*shell.Flag, args ...string) (r []byte)
- func (k *Ktrl) SetPrintLogo(f func(_ *console.Console))
- func (k *Ktrl) StartServer()
- func (k *Ktrl) StartShell() error
- type KtrlCommand
- type KtrlConf
- type KtrlContext
- func (kctx *KtrlContext) GetArgs() []string
- func (kctx *KtrlContext) GetBool(name string) (r bool)
- func (kctx *KtrlContext) GetFloat(name string) (r float64)
- func (kctx *KtrlContext) GetInt(name string) (r int)
- func (kctx *KtrlContext) GetString(name string) (r string)
- func (kctx *KtrlContext) SendResponse(content interface{}, code ...int)
- func (kctx *KtrlContext) SetArgs(args ...string)
- type Option
Constants ¶
View Source
const ( OptionTypeString FlagType = "string" OptionTypeBool FlagType = "bool" OptionTypeInt FlagType = "int" OptionTypeFloat FlagType = "float" ContextTypeClient int8 = 1 ContextTypeServer int8 = 2 QueryArgsName string = "queryArgs" )
View Source
const ( PingRoute string = "/ping/" PingResponse string = "pong" )
View Source
const (
SockName string = "ktrl_ishell.sock"
)
Variables ¶
This section is empty.
Functions ¶
func FormatRoute ¶
Types ¶
type Ktrl ¶
type Ktrl struct {
// contains filtered or unexported fields
}
func (*Ktrl) AddCommand ¶
func (k *Ktrl) AddCommand(kcmd *KtrlCommand)
func (*Ktrl) GetResult ¶
func (k *Ktrl) GetResult(ctx *KtrlContext)
func (*Ktrl) PreServerStart ¶
func (k *Ktrl) PreServerStart()
func (*Ktrl) PreShellStart ¶
func (k *Ktrl) PreShellStart()
func (*Ktrl) SetPrintLogo ¶
func (*Ktrl) StartServer ¶
func (k *Ktrl) StartServer()
func (*Ktrl) StartShell ¶
type KtrlCommand ¶
type KtrlCommand struct {
Name string // cmd name
Parent string // parent cmd name
HelpStr string // Short for cobra cmd
LongHelpStr string // Long for cobra cmd
Options []*shell.Flag // flags for cobra
SendInRunFunc bool // Send request in RunFunc
RunFunc func(ctx *KtrlContext) // Not Nil. Hook for cobra.
Handler func(ctx *KtrlContext) // Not Nil. Handler for server.
}
type KtrlContext ¶
type KtrlContext struct {
GinCtx *gin.Context
Command *cobra.Command
Route string
Options []*shell.Flag
Result []byte
Type int8
// contains filtered or unexported fields
}
func (*KtrlContext) GetArgs ¶
func (kctx *KtrlContext) GetArgs() []string
parse flags and args for server.
func (*KtrlContext) GetBool ¶
func (kctx *KtrlContext) GetBool(name string) (r bool)
func (*KtrlContext) GetFloat ¶
func (kctx *KtrlContext) GetFloat(name string) (r float64)
func (*KtrlContext) GetInt ¶
func (kctx *KtrlContext) GetInt(name string) (r int)
func (*KtrlContext) GetString ¶
func (kctx *KtrlContext) GetString(name string) (r string)
func (*KtrlContext) SendResponse ¶
func (kctx *KtrlContext) SendResponse(content interface{}, code ...int)
Send reponse back to client.
func (*KtrlContext) SetArgs ¶
func (kctx *KtrlContext) SetArgs(args ...string)
Click to show internal directories.
Click to hide internal directories.