当前位置: 首页>>代码示例>>Golang>>正文


Golang Command.AddCommand方法代码示例

本文整理汇总了Golang中github.com/spf13/cobra.Command.AddCommand方法的典型用法代码示例。如果您正苦于以下问题:Golang Command.AddCommand方法的具体用法?Golang Command.AddCommand怎么用?Golang Command.AddCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/spf13/cobra.Command的用法示例。


在下文中一共展示了Command.AddCommand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: AddDestroySub

func (a *Acl) AddDestroySub(c *cobra.Command) {
	destroyCmd := &cobra.Command{
		Use:   "destroy <token>",
		Short: "Destroy an ACL",
		Long:  "Destroy an ACL",
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Destroy(args)
		},
	}

	oldDestroyCmd := &cobra.Command{
		Use:        "acl-destroy <token>",
		Short:      "Destroy an ACL",
		Long:       "Destroy an ACL",
		Deprecated: "Use acl destroy",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Destroy(args)
		},
	}

	c.AddCommand(destroyCmd)

	a.AddCommand(oldDestroyCmd)
}
开发者ID:CiscoCloud,项目名称:consul-cli,代码行数:25,代码来源:acl_destroy.go

示例2: AddInfoSub

func (s *Session) AddInfoSub(cmd *cobra.Command) {
	infoCmd := &cobra.Command{
		Use:   "info <sessionId>",
		Short: "Get information on a session",
		Long:  "Get information on a session",
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Info(args)
		},
	}

	oldInfoCmd := &cobra.Command{
		Use:        "session-info <sessionId>",
		Short:      "Get information on a session",
		Long:       "Get information on a session",
		Deprecated: "Use session info",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Info(args)
		},
	}

	s.AddDatacenterOption(infoCmd)
	s.AddTemplateOption(infoCmd)
	s.AddConsistency(infoCmd)
	s.AddDatacenterOption(oldInfoCmd)

	cmd.AddCommand(infoCmd)

	s.AddCommand(oldInfoCmd)
}
开发者ID:CiscoCloud,项目名称:consul-cli,代码行数:30,代码来源:session_info.go

示例3: AddChecksSub

func (a *Agent) AddChecksSub(c *cobra.Command) {
	checksCmd := &cobra.Command{
		Use:   "checks",
		Short: "Get the checks the agent is managing",
		Long:  "Get the checks the agent is managing",
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Checks(args)
		},
	}

	oldChecksCmd := &cobra.Command{
		Use:        "agent-checks",
		Short:      "Get the checks the agent is managing",
		Long:       "Get the checks the agent is managing",
		Deprecated: "Use agent checks",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Checks(args)
		},
	}

	a.AddTemplateOption(checksCmd)
	c.AddCommand(checksCmd)

	a.AddCommand(oldChecksCmd)
}
开发者ID:CiscoCloud,项目名称:consul-cli,代码行数:26,代码来源:agent_checks.go

示例4: AddMembersSub

func (a *Agent) AddMembersSub(c *cobra.Command) {
	amo := &AgentMembersOptions{}

	membersCmd := &cobra.Command{
		Use:   "members",
		Short: "Get the members as seen by the serf agent",
		Long:  "Get the members as seen by the serf agent",
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Members(args, amo)
		},
	}

	oldMembersCmd := &cobra.Command{
		Use:        "agent-members",
		Short:      "Get the members as seen by the serf agent",
		Long:       "Get the members as seen by the serf agent",
		Deprecated: "Use agent members",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Members(args, amo)
		},
	}

	membersCmd.Flags().BoolVar(&amo.wanFlag, "wan", false, "Get list of WAN members instead of LAN")
	oldMembersCmd.Flags().BoolVar(&amo.wanFlag, "wan", false, "Get list of WAN members instead of LAN")

	a.AddTemplateOption(membersCmd)
	c.AddCommand(membersCmd)

	a.AddCommand(oldMembersCmd)
}
开发者ID:CiscoCloud,项目名称:consul-cli,代码行数:31,代码来源:agent_members.go

示例5: AddInfoSub

func (a *Acl) AddInfoSub(c *cobra.Command) {
	infoCmd := &cobra.Command{
		Use:   "info <token>",
		Short: "Query information about an ACL token",
		Long:  "Query information about an ACL token",
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Info(args)
		},
	}

	oldInfoCmd := &cobra.Command{
		Use:        "acl-info <token>",
		Short:      "Query information about an ACL token",
		Long:       "Query information about an ACL token",
		Deprecated: "Use acl info",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Info(args)
		},
	}

	a.AddTemplateOption(infoCmd)
	c.AddCommand(infoCmd)

	a.AddCommand(oldInfoCmd)
}
开发者ID:CiscoCloud,项目名称:consul-cli,代码行数:26,代码来源:acl_info.go

示例6: AddPassSub

func (c *Check) AddPassSub(cmd *cobra.Command) {
	cfo := &CheckPassOptions{}

	passCmd := &cobra.Command{
		Use:   "pass <checkId>",
		Short: "Mark a local check as passing",
		Long:  "Mark a local check as passing",
		RunE: func(cmd *cobra.Command, args []string) error {
			return c.Pass(args, cfo)
		},
	}

	oldPassCmd := &cobra.Command{
		Use:        "check-pass <checkId>",
		Short:      "Mark a local check as passing",
		Long:       "Mark a local check as passing",
		Deprecated: "Use check pass",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return c.Pass(args, cfo)
		},
	}

	passCmd.Flags().StringVar(&cfo.Note, "note", "", "Message to associate with check status")
	oldPassCmd.Flags().StringVar(&cfo.Note, "note", "", "Message to associate with check status")

	cmd.AddCommand(passCmd)

	c.AddCommand(oldPassCmd)
}
开发者ID:CiscoCloud,项目名称:consul-cli,代码行数:30,代码来源:check_pass.go

示例7: setupSendCommand

func setupSendCommand(rootCmd *cobra.Command) {
	var vgname, lvname, srcname string

	cmd := &cobra.Command{
		Use:   "send",
		Short: "create a stream representation of thin LV into standard output",
		Run: func(cmd *cobra.Command, args []string) {
			if len(vgname) == 0 || len(lvname) == 1 {
				fmt.Fprintln(os.Stderr, "volume group and logical volume must be provided")
				cmd.Usage()
				os.Exit(1)
			}

			sender, err := newStreamSender(vgname, lvname, srcname, os.Stdout)
			if err != nil {
				fmt.Fprintln(os.Stderr, err)
				os.Exit(2)
			}

			if err := sender.Run(); err != nil {
				fmt.Fprintln(os.Stderr, err)
				os.Exit(3)
			}

			os.Exit(0)
		},
	}

	cmd.Flags().StringVarP(&vgname, "vg", "v", "", "volume group")
	cmd.Flags().StringVarP(&lvname, "lv", "l", "", "logical volume")
	cmd.Flags().StringVarP(&srcname, "incremental", "i", "", "source logical volume")

	rootCmd.AddCommand(cmd)
}
开发者ID:yangjian,项目名称:lvbackup,代码行数:34,代码来源:lvbackup.go

示例8: AddRenewSub

func (s *Session) AddRenewSub(cmd *cobra.Command) {
	renewCmd := &cobra.Command{
		Use:   "renew <sessionId>",
		Short: "Renew the given session",
		Long:  "Renew the given session",
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Renew(args)
		},
	}

	oldRenewCmd := &cobra.Command{
		Use:        "session-renew <sessionId>",
		Short:      "Renew the given session",
		Long:       "Renew the given session",
		Deprecated: "Use session renew",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Renew(args)
		},
	}

	s.AddDatacenterOption(renewCmd)
	s.AddTemplateOption(renewCmd)
	s.AddDatacenterOption(oldRenewCmd)

	cmd.AddCommand(renewCmd)

	s.AddCommand(oldRenewCmd)
}
开发者ID:CiscoCloud,项目名称:consul-cli,代码行数:29,代码来源:session_renew.go

示例9: AddJoinSub

func (a *Agent) AddJoinSub(c *cobra.Command) {
	ajo := &AgentJoinOptions{}

	joinCmd := &cobra.Command{
		Use:   "join",
		Short: "Trigger the local agent to join a node",
		Long:  "Trigger the local agent to join a node",
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Join(args, ajo)
		},
	}

	oldJoinCmd := &cobra.Command{
		Use:        "agent-join",
		Short:      "Trigger the local agent to join a node",
		Long:       "Trigger the local agent to join a node",
		Deprecated: "Use agent join",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Join(args, ajo)
		},
	}

	joinCmd.Flags().BoolVar(&ajo.wanFlag, "wan", false, "Get list of WAN join instead of LAN")
	oldJoinCmd.Flags().BoolVar(&ajo.wanFlag, "wan", false, "Get list of WAN join instead of LAN")

	a.AddTemplateOption(joinCmd)
	c.AddCommand(joinCmd)

	a.AddCommand(oldJoinCmd)
}
开发者ID:CiscoCloud,项目名称:consul-cli,代码行数:31,代码来源:agent_join.go

示例10: AddDestroySub

func (s *Session) AddDestroySub(cmd *cobra.Command) {
	destroyCmd := &cobra.Command{
		Use:   "destroy <sessionId>",
		Short: "Destroy a session",
		Long:  "Destroy a session",
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Destroy(args)
		},
	}

	oldDestroyCmd := &cobra.Command{
		Use:        "session-destroy <sessionId>",
		Short:      "Destroy a session",
		Long:       "Destroy a session",
		Deprecated: "Use session destroy",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Destroy(args)
		},
	}

	s.AddDatacenterOption(destroyCmd)
	s.AddDatacenterOption(oldDestroyCmd)

	cmd.AddCommand(destroyCmd)

	s.AddCommand(oldDestroyCmd)
}
开发者ID:CiscoCloud,项目名称:consul-cli,代码行数:28,代码来源:session_destroy.go

示例11: AddNodeSub

func (h *Health) AddNodeSub(cmd *cobra.Command) {
	nodeCmd := &cobra.Command{
		Use:   "node <nodeName>",
		Short: "Get the health info for a node",
		Long:  "Get the health info for a node",
		RunE: func(cmd *cobra.Command, args []string) error {
			return h.Node(args)
		},
	}

	oldNodeCmd := &cobra.Command{
		Use:        "health-node <nodeName>",
		Short:      "Get the health info for a node",
		Long:       "Get the health info for a node",
		Deprecated: "Use health node",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return h.Node(args)
		},
	}

	h.AddDatacenterOption(nodeCmd)
	h.AddDatacenterOption(oldNodeCmd)
	h.AddTemplateOption(nodeCmd)
	h.AddConsistency(nodeCmd)

	cmd.AddCommand(nodeCmd)

	h.AddCommand(oldNodeCmd)
}
开发者ID:CiscoCloud,项目名称:consul-cli,代码行数:30,代码来源:health_node.go

示例12: AddNodeSub

func (s *Session) AddNodeSub(cmd *cobra.Command) {
	nodeCmd := &cobra.Command{
		Use:   "node <nodeName>",
		Short: "Get active sessions for a node",
		Long:  "Get active sessions for a node",
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Node(args)
		},
	}

	oldNodeCmd := &cobra.Command{
		Use:        "session-node <nodeName>",
		Short:      "Get active sessions for a node",
		Long:       "Get active sessions for a node",
		Deprecated: "Use session node",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Node(args)
		},
	}

	s.AddDatacenterOption(nodeCmd)
	s.AddTemplateOption(nodeCmd)
	s.AddConsistency(nodeCmd)
	s.AddDatacenterOption(oldNodeCmd)

	cmd.AddCommand(nodeCmd)

	s.AddCommand(oldNodeCmd)
}
开发者ID:CiscoCloud,项目名称:consul-cli,代码行数:30,代码来源:session_node.go

示例13: AddMaintenanceSub

func (s *Service) AddMaintenanceSub(cmd *cobra.Command) {
	smo := &ServiceMaintenanceOptions{}

	maintenanceCmd := &cobra.Command{
		Use:   "maintenance",
		Short: "Manage maintenance mode of a service",
		Long:  "Manage maintenance mode of a service",
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Maintenance(args, smo)
		},
	}

	oldMaintenanceCmd := &cobra.Command{
		Use:        "service-maintenance",
		Short:      "Manage maintenance mode of a service",
		Long:       "Manage maintenance mode of a service",
		Deprecated: "Use agent maintenance",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Maintenance(args, smo)
		},
	}

	maintenanceCmd.Flags().BoolVar(&smo.enabled, "enabled", true, "Boolean value for maintenance mode")
	maintenanceCmd.Flags().StringVar(&smo.reason, "reason", "", "Reason for entering maintenance mode")
	oldMaintenanceCmd.Flags().BoolVar(&smo.enabled, "enabled", true, "Boolean value for maintenance mode")
	oldMaintenanceCmd.Flags().StringVar(&smo.reason, "reason", "", "Reason for entering maintenance mode")

	s.AddTemplateOption(maintenanceCmd)
	cmd.AddCommand(maintenanceCmd)

	s.AddCommand(oldMaintenanceCmd)
}
开发者ID:CiscoCloud,项目名称:consul-cli,代码行数:33,代码来源:service_maintenance.go

示例14: AddServicesSub

func (a *Agent) AddServicesSub(c *cobra.Command) {
	servicesCmd := &cobra.Command{
		Use:   "services",
		Short: "Get the services the agent is managing",
		Long:  "Get the services the agent is managing",
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Services(args)
		},
	}

	oldServicesCmd := &cobra.Command{
		Use:        "agent-services",
		Short:      "Get the services the agent is managing",
		Long:       "Get the services the agent is managing",
		Deprecated: "Use agent services",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Services(args)
		},
	}

	a.AddTemplateOption(servicesCmd)
	c.AddCommand(servicesCmd)

	a.AddCommand(oldServicesCmd)
}
开发者ID:CiscoCloud,项目名称:consul-cli,代码行数:26,代码来源:agent_services.go

示例15: AddDatacentersSub

func (c *Catalog) AddDatacentersSub(cmd *cobra.Command) {
	datacentersCmd := &cobra.Command{
		Use:   "datacenters",
		Short: "Get all the datacenters known by the Consul server",
		Long:  "Get all the datacenters known by the Consul server",
		RunE: func(cmd *cobra.Command, args []string) error {
			return c.Datacenters(args)
		},
	}

	oldDatacentersCmd := &cobra.Command{
		Use:        "catalog-datacenters",
		Short:      "Get all the datacenters known by the Consul server",
		Long:       "Get all the datacenters known by the Consul server",
		Deprecated: "Use catalog datacenters",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return c.Datacenters(args)
		},
	}

	c.AddTemplateOption(datacentersCmd)
	cmd.AddCommand(datacentersCmd)

	c.AddCommand(oldDatacentersCmd)
}
开发者ID:CiscoCloud,项目名称:consul-cli,代码行数:26,代码来源:catalog_datacenters.go


注:本文中的github.com/spf13/cobra.Command.AddCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。