MCPcopy Index your code
hub / github.com/deepflowio/deepflow / ClientRegisterSimple

Function ClientRegisterSimple

server/libs/debug/simple_debug.go:51–98  ·  view source on GitHub ↗

client注册命令

(moduleId ModuleId, module CmdHelper, operates []CmdHelper)

Source from the content-addressed store, hash-verified

49
50// client注册命令
51func ClientRegisterSimple(moduleId ModuleId, module CmdHelper, operates []CmdHelper) *cobra.Command {
52 command := &cobra.Command{
53 Use: module.Cmd,
54 Short: module.Helper,
55 Run: func(cmd *cobra.Command, args []string) {
56 if len(operates) == 0 {
57 arg := ""
58 if len(args) > 0 {
59 arg = args[0]
60 }
61 result, err := CommmandGetResult(moduleId, 0, arg)
62 if err != nil {
63 fmt.Println("Get result failed", err)
64 return
65 }
66 fmt.Println(result)
67 return
68 }
69 fmt.Printf("please run with arguments: ")
70 for _, operate := range operates {
71 fmt.Printf("\n %-32s : %s", operate.Cmd, operate.Helper)
72 }
73 fmt.Println()
74 },
75 }
76
77 for i, operate := range operates {
78 op := i
79 sub := &cobra.Command{
80 Use: operate.Cmd,
81 Short: operate.Helper,
82 Run: func(cmd *cobra.Command, args []string) {
83 arg := ""
84 if len(args) > 0 {
85 arg = args[0]
86 }
87 result, err := CommmandGetResult(moduleId, op, arg)
88 if err != nil {
89 fmt.Println("Get result failed", err)
90 return
91 }
92 fmt.Println(result)
93 },
94 }
95 command.AddCommand(sub)
96 }
97 return command
98}
99
100func RecvFromServerMulti(conn *net.UDPConn) (*bytes.Buffer, error) {
101 ret := bytes.NewBuffer(make([]byte, 0))

Callers

nothing calls this directly

Calls 1

CommmandGetResultFunction · 0.85

Tested by

no test coverage detected