-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommand.go
49 lines (38 loc) · 1.27 KB
/
command.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package gonsole
import (
"github.com/lixianmin/gonsole/road"
"github.com/lixianmin/got/loom"
)
/********************************************************************
created: 2020-06-04
author: lixianmin
Copyright (C) - All Rights Reserved
*********************************************************************/
type Command struct {
loom.Flag // command的flag
Name string // 名称
Example string // 示例
Note string // 描述
Handler func(client road.Session, args []string) (*Response, error) // 处理方法
}
func (cmd *Command) GetName() string {
return cmd.Name
}
func (cmd *Command) GetExample() string {
return cmd.Example
}
func (cmd *Command) GetNote() string {
return cmd.Note
}
func (cmd *Command) IsBuiltin() bool {
return cmd.HasFlag(flagBuiltin)
}
func (cmd *Command) IsPublic() bool {
return cmd.HasFlag(FlagPublic)
}
func (cmd *Command) IsInvisible() bool {
return cmd.HasFlag(FlagInvisible)
}
func (cmd *Command) Run(session road.Session, args []string) (*Response, error) {
return cmd.Handler(session, args)
}