func updateCorePlugin(ctx api.Context) error {
	cluster, err := ctx.Cluster()
	if err != nil {
		return err
	}
	cosmosClient, err := cosmos.NewClient()
	if err != nil {
		return err
	}
	pkg, _, err := cosmosClient.PackageDescribe(context.TODO(), &dcosclient.PackageDescribeOpts{
		CosmosPackageDescribeV1Request: optional.NewInterface(dcosclient.CosmosPackageDescribeV1Request{
			PackageName: "dcos-core-cli",
		}),
	})
	if err != nil {
		return err
	}
	httpClient, err := ctx.HTTPClient(cluster)
	if err != nil {
		return err
	}
	pluginInfo, err := cosmos.CLIPluginInfo(pkg, httpClient.BaseURL())
	if err != nil {
		return err
	}
	_, err = ctx.PluginManager(cluster).Install(pluginInfo.Url, &plugin.InstallOpts{
		Name:   "dcos-core-cli",
		Update: true,
		PostInstall: func(fs afero.Fs, pluginDir string) error {
			pkgInfoFilepath := filepath.Join(pluginDir, "package.json")
			pkgInfoFile, err := fs.OpenFile(pkgInfoFilepath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
			if err != nil {
				return err
			}
			defer pkgInfoFile.Close()
			return json.NewEncoder(pkgInfoFile).Encode(pkg.Package)
		},
	})
	return err
}
updateCorePlugin updates the core CLI plugin.
package cmd
import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"os/exec"
	"path/filepath"
	"strings"
	"text/template"
	"github.com/antihax/optional"
	dcosclient "github.com/dcos/client-go/dcos"
	"github.com/sirupsen/logrus"
	"github.com/spf13/afero"
	"github.com/spf13/cobra"
	"github.com/spf13/pflag"
	"github.com/dcos/dcos-cli/api"
	"github.com/dcos/dcos-cli/pkg/cli/version"
	"github.com/dcos/dcos-cli/pkg/cmd/auth"
	clustercmd "github.com/dcos/dcos-cli/pkg/cmd/cluster"
	"github.com/dcos/dcos-cli/pkg/cmd/completion"
	configcmd "github.com/dcos/dcos-cli/pkg/cmd/config"
	plugincmd "github.com/dcos/dcos-cli/pkg/cmd/plugin"
	"github.com/dcos/dcos-cli/pkg/config"
	"github.com/dcos/dcos-cli/pkg/internal/cosmos"
	"github.com/dcos/dcos-cli/pkg/plugin"
)
const annotationUsageOptions string = `    --version
        Print version information
    -v, -vv
        Output verbosity (verbose or very verbose)
    -h, --help
        Show usage help`
func NewDCOSCommand(ctx api.Context) *cobra.Command {
	cmd := &cobra.Command{
		Use:  "dcos",
		Args: cobra.ArbitraryArgs,
	}
	cmd.AddCommand(
		auth.NewCommand(ctx),
		configcmd.NewCommand(ctx),
		clustercmd.NewCommand(ctx),
		plugincmd.NewCommand(ctx),
		completion.NewCommand(ctx),
	)
	if cluster, err := ctx.Cluster(); err == nil {
		pluginManager := ctx.PluginManager(cluster)
		for _, plugin := range pluginManager.Plugins() {
			for _, pluginCmd := range plugin.Commands {
				cmd.AddCommand(newPluginCommand(ctx, pluginCmd))
			}
		}
	}
	cmd.SetUsageFunc(helpMenuFunc)
	cmd.SilenceUsage = true
	return cmd
}
func newPluginCommand(ctx api.Context, cmd plugin.Command) *cobra.Command {
	pluginCmd := &cobra.Command{
		Use:                cmd.Name,
		Short:              cmd.Description,
		DisableFlagParsing: true,
		SilenceErrors:      true,  
		SilenceUsage:       true,  
		RunE: func(_ *cobra.Command, _ []string) error {
			ctxArgs := ctx.Args()
			var cmdArgs []string
			for key, arg := range ctxArgs {
				if arg == cmd.Name {
					cmdArgs = ctxArgs[key:]
					break
				}
			}
			if len(cmdArgs) >= 3 && cmdArgs[0] == "package" && cmdArgs[1] == "install" && cmdArgs[2] == "dcos-core-cli" {
				return updateCorePlugin(ctx)
			}
			return invokePlugin(ctx, cmd, cmdArgs)
		},
	}
	pluginCmd.SetHelpFunc(func(_ *cobra.Command, cmdArgs []string) {
		args := []string{cmd.Name}
		args = append(args, cmdArgs...)
		args = append(args, "--help")
		invokePlugin(ctx, cmd, args)
	})
	return pluginCmd
}