goc/cmd/list.go
lyyyuna 456c883987 重构
1. 去掉全局的配置 config
2. 合并 pkg/build, pkg/flag, pkg/cover, pkg/config 几个包(这几个包有强相关性,适合放一处。并且分开也容易造成循环依赖)
2021-09-02 14:43:08 +08:00

33 lines
680 B
Go

package cmd
import (
"github.com/qiniu/goc/v2/pkg/client"
"github.com/spf13/cobra"
)
var listCmd = &cobra.Command{
Use: "list",
Short: "Lists all the registered services",
Long: "Lists all the registered services",
Example: `
goc list [flags]
`,
Run: list,
}
var (
listHost string
listWide bool
)
func init() {
listCmd.Flags().StringVar(&listHost, "host", "127.0.0.1:7777", "specify the host of the goc server")
listCmd.Flags().BoolVar(&listWide, "wide", false, "list all services with more information (such as pid)")
rootCmd.AddCommand(listCmd)
}
func list(cmd *cobra.Command, args []string) {
client.NewWorker("http://" + listHost).ListAgents(listWide)
}