forked from goravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apifox_list_command.go
49 lines (41 loc) · 1.04 KB
/
apifox_list_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 console
import (
"errors"
"fmt"
"strings"
"github.com/gookit/color"
"github.com/mewway/go-laravel/contracts/console"
"github.com/mewway/go-laravel/contracts/console/command"
"github.com/mewway/go-laravel/doc/apifox"
)
type ApifoxListCommand struct {
artisan console.Artisan
}
func NewApifoxListCommand(atrisan console.Artisan) *ApifoxListCommand {
return &ApifoxListCommand{
artisan: atrisan,
}
}
func (y ApifoxListCommand) Signature() string {
return "doc:apifox-list"
}
func (y ApifoxListCommand) Description() string {
return "List all apifox api list"
}
func (y ApifoxListCommand) Extend() command.Extend {
return command.Extend{
Category: "doc",
}
}
func (y ApifoxListCommand) Handle(ctx console.Context) error {
c := apifox.NewClient()
if c == nil {
return errors.New("please complete the doc configuration first")
}
l := c.QueryApiList()
color.Cyanln("Apifox api list:")
for i, v := range l.Data {
color.Grayln(fmt.Sprintf("%d.【%s】%s: %s", i+1, strings.ToUpper(v.Method), v.Path, v.Name))
}
return nil
}