Golang Command.AddCommand Examples

Golang Command.AddCommand - 30 examples found. These are the top rated real world Golang examples of github.com/spf13/cobra.Command.AddCommand extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
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)
}
Example #2
0
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)
}
Example #3
0
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)
}
Example #4
0
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)
}
Example #5
0
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)
}
Example #6
0
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)
}