goc/cmd/list.go

31 lines
722 B
Go
Raw Normal View History

2021-07-12 08:39:16 +00:00
package cmd
import (
"github.com/qiniu/goc/v2/pkg/client"
"github.com/qiniu/goc/v2/pkg/config"
"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,
}
2021-07-12 12:09:45 +00:00
var listWide bool
2021-07-12 08:39:16 +00:00
func init() {
2021-07-12 12:09:45 +00:00
listCmd.Flags().StringVar(&config.GocConfig.Host, "host", "127.0.0.1:7777", "specify the host of the goc server")
2021-07-19 08:31:42 +00:00
listCmd.Flags().BoolVar(&listWide, "wide", false, "list all services with more information (such as pid)")
2021-07-12 08:39:16 +00:00
rootCmd.AddCommand(listCmd)
}
func list(cmd *cobra.Command, args []string) {
2021-07-12 12:09:45 +00:00
client.NewWorker("http://" + config.GocConfig.Host).ListAgents(listWide)
2021-07-12 08:39:16 +00:00
}