func CommandFor(basename string) *cobra.Command {
	var cmd *cobra.Command

	in, out, errout := os.Stdin, os.Stdout, os.Stderr

	// Make case-insensitive and strip executable suffix if present
	if runtime.GOOS == "windows" {
		basename = strings.ToLower(basename)
		basename = strings.TrimSuffix(basename, ".exe")
	}

	switch basename {
	case "kubectl":
		cmd = kubecmd.NewDefaultKubectlCommand()
	case "openshift-deploy":
		cmd = deployer.NewCommandDeployer(basename)
	case "openshift-recycle":
		cmd = recycle.NewCommandRecycle(basename, out)
	default:
		shimKubectlForOc()
		cmd = NewDefaultOcCommand(in, out, errout)

		// treat oc as a kubectl plugin
		if strings.HasPrefix(basename, "kubectl-") {
			args := strings.Split(strings.TrimPrefix(basename, "kubectl-"), "-")

			// the plugin mechanism interprets "_" as dashes. Convert any "_" our basename
			// might have in order to find the appropriate command in the `oc` tree.
			for i := range args {
				args[i] = strings.Replace(args[i], "_", "-", -1)
			}

			if targetCmd, _, err := cmd.Find(args); targetCmd != nil && err == nil {
				// since cobra refuses to execute a child command, executing its root
				// any time Execute() is called, we must create a completely new command
				// and "deep copy" the targetCmd information to it.
				newParent := &cobra.Command{
					Use:     targetCmd.Use,
					Short:   targetCmd.Short,
					Long:    targetCmd.Long,
					Example: targetCmd.Example,
					Run:     targetCmd.Run,
				}

				// copy flags
				newParent.Flags().AddFlagSet(cmd.Flags())
				newParent.Flags().AddFlagSet(targetCmd.Flags())
				newParent.PersistentFlags().AddFlagSet(targetCmd.PersistentFlags())

				// copy subcommands
				newParent.AddCommand(targetCmd.Commands()...)
				cmd = newParent
			}
		}
	}

	if cmd.UsageFunc() == nil {
		cmdutil.ActsAsRootCommand(cmd, []string{"options"})
	}
	return cmd
}
// CommandFor returns the appropriate command for this base name,
// or the OpenShift CLI command.
CommandFor returns the appropriate command for this base name,
or the OpenShift CLI command.
// CommandFor returns the appropriate command for this base name // or the OpenShift CLI command .
func CommandFor(basename string) *cobra.Command {
	var cmd *cobra.Command
	in, out, errout := os.Stdin, os.Stdout, os.Stderr
	if runtime.GOOS == "windows" {
		basename = strings.ToLower(basename)
		basename = strings.TrimSuffix(basename, ".exe")
	}
	switch basename {
	case "kubectl":
		cmd = kubecmd.NewDefaultKubectlCommand()
	case "openshift-deploy":
		cmd = deployer.NewCommandDeployer(basename)
	case "openshift-recycle":
		cmd = recycle.NewCommandRecycle(basename, out)
	default:
		shimKubectlForOc()
		cmd = NewDefaultOcCommand(in, out, errout)
		if strings.HasPrefix(basename, "kubectl-") {
			args := strings.Split(strings.TrimPrefix(basename, "kubectl-"), "-")
			for i := range args {
				args[i] = strings.Replace(args[i], "_", "-", -1)
			}
			if targetCmd, _, err := cmd.Find(args); targetCmd != nil && err == nil {
				newParent := &cobra.Command{
					Use:     targetCmd.Use,
					Short:   targetCmd.Short,
					Long:    targetCmd.Long,
					Example: targetCmd.Example,
					Run:     targetCmd.Run,
				}
				newParent.Flags().AddFlagSet(cmd.Flags())
				newParent.Flags().AddFlagSet(targetCmd.Flags())
				newParent.PersistentFlags().AddFlagSet(targetCmd.PersistentFlags())
				newParent.AddCommand(targetCmd.Commands()...)
				cmd = newParent
			}
		}
	}
	if cmd.UsageFunc() == nil {
		cmdutil.ActsAsRootCommand(cmd, []string{"options"})
	}
	return cmd
}
func CommandFor ( basename string ) * cobra . Command { var cmd * cobra . Command in , out , errout := os . Stdin , os . Stdout , os . Stderr if runtime . GOOS == " " { basename = strings . ToLower ( basename ) basename = strings . TrimSuffix ( basename , " " ) } switch basename { case " " : cmd = kubecmd . NewDefaultKubectlCommand ( ) case " " : cmd = deployer . NewCommandDeployer ( basename ) case " " : cmd = recycle . NewCommandRecycle ( basename , out ) default : shimKubectlForOc ( ) cmd = NewDefaultOcCommand ( in , out , errout ) if strings . HasPrefix ( basename , " " ) { args := strings . Split ( strings . TrimPrefix ( basename , " " ) , " " ) for i := range args { args [ i ] = strings . Replace ( args [ i ] , " " , " " , - 1 ) } if targetCmd , _ , err := cmd . Find ( args ) ; targetCmd != nil && err == nil { newParent := & cobra . Command { Use : targetCmd . Use , Short : targetCmd . Short , Long : targetCmd . Long , Example : targetCmd . Example , Run : targetCmd . Run , } newParent . Flags ( ) . AddFlagSet ( cmd . Flags ( ) ) newParent . Flags ( ) . AddFlagSet ( targetCmd . Flags ( ) ) newParent . PersistentFlags ( ) . AddFlagSet ( targetCmd . PersistentFlags ( ) ) newParent . AddCommand ( targetCmd . Commands ( ) ... ) cmd = newParent } } } if cmd . UsageFunc ( ) == nil { cmdutil . ActsAsRootCommand ( cmd , [ ] string { " " } ) } return cmd }
CommandFor returns the appropriate command for this base name,
or the OpenShift CLI command.
CommandFor returns the appropriate command for this base name or the OpenShift CLI command .
// Make case-insensitive and strip executable suffix if present // treat oc as a kubectl plugin // the plugin mechanism interprets "_" as dashes. Convert any "_" our basename // might have in order to find the appropriate command in the `oc` tree. // since cobra refuses to execute a child command, executing its root // any time Execute() is called, we must create a completely new command // and "deep copy" the targetCmd information to it. // copy flags // copy subcommands