func (c *baseCommand) EmbeddedCommand() *cobra.Command {
	return &c.Command
}
EmbeddedCommand get embedded command
package cli
import (
	"errors"
	"github.com/spf13/cobra"
	"github.com/spf13/pflag"
	"hidevops.io/hiboot/pkg/at"
	"hidevops.io/hiboot/pkg/system/types"
	"hidevops.io/hiboot/pkg/utils/reflector"
	"io"
	"reflect"
	"strings"
)
type Command interface {
	EmbeddedCommand() *cobra.Command
	Add(commands ...Command) Command
	HasChild() bool
	Children() []Command
	Exec() error
	GetName() string
	FullName() string
	SetName(name string) Command
	SetFullName(name string) Command
	Parent() Command
	SetParent(p Command) Command
	Run(args []string) error
	Find(name string) (Command, error)
	SetOutput(output io.Writer)
	SetArgs(a []string)
	ExecuteC() (cmd *cobra.Command, err error)
	PersistentFlags() *pflag.FlagSet
}
const (
	actionPrefix = "On"
)
var ErrCommandNotFound = errors.New("command not found")
var ErrCommandHandlerNotFound = errors.New("command handler not found")
type baseCommand struct {
	cobra.Command
	name     string
	fullName string
	parent   Command
	children []Command
}
type RootCommand struct {
	at.Qualifier `value:"cli.rootCommand"`
	baseCommand
}
type SubCommand struct {
	baseCommand
}
func Dispatch(c Command, args []string) (retVal interface{}, err error) {
	if len(args) > 0 && args[0] != "" {
		methodName := actionPrefix + strings.Title(args[0])
		retVal, err = reflector.CallMethodByName(c, methodName, args[1:])
		return
	}
	return nil, ErrCommandHandlerNotFound
}
func Register(c Command) {
	var next bool
	c.EmbeddedCommand().RunE = func(cmd *cobra.Command, args []string) error {
		result, err := Dispatch(c, args)
		if err == nil && result != nil {
			typ := reflect.TypeOf(result)
			typName := typ.Name()
			switch typName {
			case types.Bool:
				next = result.(bool)
			default:
				return result.(error)
			}
		} else {
			next = true
		}
		if next {
			return c.Run(args)
		}
		return nil
	}
}