|
| 1 | +// +build gopacket |
| 2 | + |
| 3 | +package executors |
| 4 | + |
| 5 | +import ( |
| 6 | + "fmt" |
| 7 | + "strings" |
| 8 | + |
| 9 | + "github.com/lflxp/showme/completers" |
| 10 | + "github.com/lflxp/showme/executors/dashboard" |
| 11 | + "github.com/lflxp/showme/executors/gopacket" |
| 12 | + "github.com/lflxp/showme/executors/helloworld" |
| 13 | + "github.com/lflxp/showme/executors/layout" |
| 14 | + "github.com/lflxp/showme/executors/monitor" |
| 15 | + "github.com/lflxp/showme/executors/scan" |
| 16 | + "github.com/lflxp/showme/utils" |
| 17 | +) |
| 18 | + |
| 19 | +/** 解析执行命令函数 |
| 20 | +@param in // command from |
| 21 | +@result func() // function |
| 22 | +@result bool // 状态 是否执行 |
| 23 | +*/ |
| 24 | +func ParseExecutors(in string) (func(), bool) { |
| 25 | + var result func() |
| 26 | + status := false |
| 27 | + if in == "dashboard show" { |
| 28 | + result = func() { |
| 29 | + dashboard.Run() |
| 30 | + } |
| 31 | + status = true |
| 32 | + } else if in == "dashboard helloworld" { |
| 33 | + result = func() { |
| 34 | + helloworld.Run() |
| 35 | + } |
| 36 | + status = true |
| 37 | + } else if in == "gocui active" { |
| 38 | + result = func() { |
| 39 | + layout.Run() |
| 40 | + } |
| 41 | + status = true |
| 42 | + } else if in == "dashboard" { |
| 43 | + result = func() { |
| 44 | + dashboard.Dashboard() |
| 45 | + } |
| 46 | + status = true |
| 47 | + } else if strings.Contains(in, "monitor") { |
| 48 | + result = func() { |
| 49 | + monitor.Run(in) |
| 50 | + } |
| 51 | + status = true |
| 52 | + } else if in == "help" { |
| 53 | + result = func() { |
| 54 | + completers.Help() |
| 55 | + } |
| 56 | + status = true |
| 57 | + } else if strings.Contains(in, "gopacket") { |
| 58 | + if strings.Contains(in, "gopacket in") { |
| 59 | + result = func() { |
| 60 | + gopacket.Run(in) |
| 61 | + } |
| 62 | + } |
| 63 | + if strings.Contains(in, "gopacket screen") { |
| 64 | + result = func() { |
| 65 | + // gopacket.Gopacket(in) |
| 66 | + gopacket.Screen(strings.Split(in, " ")[2]) |
| 67 | + } |
| 68 | + } |
| 69 | + status = true |
| 70 | + } else if strings.Contains(in, "scan") { |
| 71 | + result = func() { |
| 72 | + scan.Scan(in) |
| 73 | + } |
| 74 | + status = true |
| 75 | + } else { |
| 76 | + fmt.Println(utils.Colorize(in, "red", "black", true, true), " not found executors") |
| 77 | + } |
| 78 | + return result, status |
| 79 | +} |
0 commit comments