From 987a5acd46afa24c2acb4a4be0a9c5a3e59f907e Mon Sep 17 00:00:00 2001 From: alan Date: Sat, 11 Apr 2020 23:14:24 +0800 Subject: [PATCH] group command for easy read Signed-off-by: Alan Zhu Signed-off-by: Matheus Hunsche --- cmd/helm/root.go | 63 ++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/cmd/helm/root.go b/cmd/helm/root.go index ca23ac527..fd5491803 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -26,6 +26,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/clientcmd" + "k8s.io/kubectl/pkg/util/templates" "helm.sh/helm/v3/internal/completion" "helm.sh/helm/v3/internal/experimental/registry" @@ -134,31 +135,47 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string flags.ParseErrorsWhitelist.UnknownFlags = true flags.Parse(args) + commandGroups := templates.CommandGroups{ + { + Message: "Release Management Commands:", + Commands: []*cobra.Command{ + newInstallCmd(actionConfig, out), + newListCmd(actionConfig, out), + newGetCmd(actionConfig, out), + newStatusCmd(actionConfig, out), + newUpgradeCmd(actionConfig, out), + newHistoryCmd(actionConfig, out), + newRollbackCmd(actionConfig, out), + newReleaseTestCmd(actionConfig, out), + newUninstallCmd(actionConfig, out), + }, + }, + { + Message: "Chart Commands:", + Commands: []*cobra.Command{ + newCreateCmd(out), + newDependencyCmd(out), + newPackageCmd(out), + newTemplateCmd(actionConfig, out), + newLintCmd(out), + newVerifyCmd(out), + }, + }, + { + Message: "Chart Repository Commands:", + Commands: []*cobra.Command{ + newRepoCmd(out), + newSearchCmd(out), + newPullCmd(out), + newShowCmd(out), + }, + }, + } + commandGroups.Add(cmd) + templates.ActsAsRootCommand(cmd, []string{"options"}, commandGroups...) + // Add subcommands cmd.AddCommand( - // chart commands - newCreateCmd(out), - newDependencyCmd(out), - newPullCmd(out), - newShowCmd(out), - newLintCmd(out), - newPackageCmd(out), - newRepoCmd(out), - newSearchCmd(out), - newVerifyCmd(out), - - // release commands - newGetCmd(actionConfig, out), - newHistoryCmd(actionConfig, out), - newInstallCmd(actionConfig, out), - newListCmd(actionConfig, out), - newReleaseTestCmd(actionConfig, out), - newRollbackCmd(actionConfig, out), - newStatusCmd(actionConfig, out), - newTemplateCmd(actionConfig, out), - newUninstallCmd(actionConfig, out), - newUpgradeCmd(actionConfig, out), - newCompletionCmd(out), newEnvCmd(out), newPluginCmd(out),