3 Star 2 Fork 0

info-superbahn-ict / superbahn

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
agent.go 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
Fhl 提交于 2021-12-07 16:09 . 1207 update
package supbagent
import (
"context"
"fmt"
rootOpt "gitee.com/info-superbahn-ict/superbahn/internal/supbctl/options"
"gitee.com/info-superbahn-ict/superbahn/internal/supbctl/supbagent/commands_nervous"
"gitee.com/info-superbahn-ict/superbahn/internal/supbctl/supbagent/options"
"github.com/spf13/cobra"
)
func InstallAgentFlags(ctx context.Context, rootCmd *cobra.Command, c *rootOpt.Opts) {
// todo 导入全局参数
var agentOpts = &options.AgentOpts{}
agentOpts.Apply(c)
// todo Get
agentCli := &cobra.Command{
Use: "agent",
Short: "superbahn agent commands",
RunE: func(cmd *cobra.Command, args []string) error {
return agentInfo(agentOpts)
},
TraverseChildren: true,
}
// todo 默认参数配置
options.ReadAgentEnvOptions()
agentCli.PersistentFlags().StringVarP(&agentOpts.AgentGuid, "connect", "c", options.AgentGuid, "connect an agent then send a command")
// todo 挂钩子
rootCmd.AddCommand(agentCli)
// todo 当然可以继续添加子命令层级,仿照root添加方式即可,在 ManagerCmd.AddCommand(子命令)
commands_nervous.InstallAgentCommandsFlags(ctx, agentCli, agentOpts)
}
func agentInfo(opts *options.AgentOpts) error {
fmt.Printf("NOTE:\n\t agent [get|create|delete|...] [OPTIONS] [ARG...]\n")
return nil
}
Go
1
https://gitee.com/info-superbahn-ict/superbahn.git
git@gitee.com:info-superbahn-ict/superbahn.git
info-superbahn-ict
superbahn
superbahn
5fda629dab96

搜索帮助

53164aa7 5694891 3bd8fe86 5694891