UI: improve minikube help output by grouping into categories (#4879)

* Improve minikube help output by grouping into categories

* consistant colon

* Add configuration category to grouped commands
pull/4786/head
Medya Ghazizadeh 2019-07-29 15:04:44 -07:00 committed by Sharif Elgamal
parent 61e1261be5
commit 165c1afd33
22 changed files with 68 additions and 52 deletions

View File

@ -108,5 +108,4 @@ func loadCachedImagesInConfigFile() error {
func init() {
cacheCmd.AddCommand(addCacheCmd)
cacheCmd.AddCommand(deleteCacheCmd)
RootCmd.AddCommand(cacheCmd)
}

View File

@ -279,7 +279,3 @@ __minikube_bash_source <(__minikube_convert_bash_to_zsh)
return nil
}
func init() {
RootCmd.AddCommand(completionCmd)
}

View File

@ -228,5 +228,4 @@ func checkURL(url string) error {
func init() {
dashboardCmd.Flags().BoolVar(&dashboardURLMode, "url", false, "Display dashboard URL instead of opening a browser")
RootCmd.AddCommand(dashboardCmd)
}

View File

@ -103,7 +103,3 @@ func uninstallKubernetes(api libmachine.API, kc pkg_config.KubernetesConfig, bsN
out.ErrT(out.Empty, "Failed to delete cluster: {{.error}}", out.V{"error": err})
}
}
func init() {
RootCmd.AddCommand(deleteCmd)
}

View File

@ -382,7 +382,6 @@ var dockerEnvCmd = &cobra.Command{
}
func init() {
RootCmd.AddCommand(dockerEnvCmd)
defaultShellDetector = &LibmachineShellDetector{}
defaultNoProxyGetter = &EnvNoProxyGetter{}
dockerEnvCmd.Flags().BoolVar(&noProxy, "no-proxy", false, "Add machine IP to NO_PROXY environment variable")

View File

@ -54,7 +54,3 @@ var ipCmd = &cobra.Command{
out.Ln(ip)
},
}
func init() {
RootCmd.AddCommand(ipCmd)
}

View File

@ -86,7 +86,3 @@ kubectl get pods --namespace kube-system`,
}
},
}
func init() {
RootCmd.AddCommand(kubectlCmd)
}

View File

@ -98,5 +98,4 @@ func init() {
logsCmd.Flags().BoolVarP(&followLogs, "follow", "f", false, "Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.")
logsCmd.Flags().BoolVar(&showProblems, "problems", false, "Show only log entries which point to known problems")
logsCmd.Flags().IntVarP(&numberOfLines, "length", "n", 50, "Number of lines back to go within the log")
RootCmd.AddCommand(logsCmd)
}

View File

@ -209,5 +209,4 @@ func init() {
mountCmd.Flags().UintVar(&mode, "mode", 0755, "File permissions used for the mount")
mountCmd.Flags().StringSliceVar(&options, "options", []string{}, "Additional mount options, such as cache=fscache")
mountCmd.Flags().IntVar(&mSize, "msize", constants.DefaultMsize, "The number of bytes to use for 9p packet payload")
RootCmd.AddCommand(mountCmd)
}

View File

@ -30,6 +30,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"k8s.io/kubectl/pkg/util/templates"
configCmd "k8s.io/minikube/cmd/minikube/cmd/config"
"k8s.io/minikube/pkg/minikube/bootstrapper"
"k8s.io/minikube/pkg/minikube/bootstrapper/kubeadm"
@ -128,9 +129,66 @@ func setFlagsUsingViper() {
func init() {
RootCmd.PersistentFlags().StringP(config.MachineProfile, "p", constants.DefaultMachineName, `The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently.`)
RootCmd.PersistentFlags().StringP(configCmd.Bootstrapper, "b", constants.DefaultClusterBootstrapper, "The name of the cluster bootstrapper that will set up the kubernetes cluster.")
RootCmd.AddCommand(configCmd.ConfigCmd)
RootCmd.AddCommand(configCmd.AddonsCmd)
RootCmd.AddCommand(configCmd.ProfileCmd)
groups := templates.CommandGroups{
{
Message: "Basic Commands:",
Commands: []*cobra.Command{
startCmd,
statusCmd,
stopCmd,
deleteCmd,
dashboardCmd,
},
},
{
Message: "Images Commands:",
Commands: []*cobra.Command{
dockerEnvCmd,
cacheCmd,
},
},
{
Message: "Configuration and Management Commands:",
Commands: []*cobra.Command{
configCmd.AddonsCmd,
configCmd.ConfigCmd,
configCmd.ProfileCmd,
updateContextCmd,
},
},
{
Message: "Networking and Connectivity Commands:",
Commands: []*cobra.Command{
serviceCmd,
tunnelCmd,
},
},
{
Message: "Advanced Commands:",
Commands: []*cobra.Command{
mountCmd,
sshCmd,
kubectlCmd,
},
},
{
Message: "Troubleshooting Commands:",
Commands: []*cobra.Command{
sshKeyCmd,
ipCmd,
logsCmd,
updateCheckCmd,
versionCmd,
},
},
}
groups.Add(RootCmd)
// any not grouped command will show in Other Commands group.
RootCmd.AddCommand(completionCmd)
templates.ActsAsRootCommand(RootCmd, []string{"options"}, groups...)
pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)
if err := viper.BindPFlags(RootCmd.PersistentFlags()); err != nil {
exit.WithError("Unable to bind flags", err)

View File

@ -83,5 +83,4 @@ func init() {
serviceCmd.PersistentFlags().StringVar(&serviceURLFormat, "format", defaultServiceFormatTemplate, "Format to output service URL in. This format will be applied to each url individually and they will be printed one at a time.")
RootCmd.AddCommand(serviceCmd)
}

View File

@ -34,7 +34,3 @@ var sshKeyCmd = &cobra.Command{
out.Ln(filepath.Join(constants.GetMinipath(), "machines", config.GetMachineName(), "id_rsa"))
},
}
func init() {
RootCmd.AddCommand(sshKeyCmd)
}

View File

@ -55,7 +55,3 @@ var sshCmd = &cobra.Command{
}
},
}
func init() {
RootCmd.AddCommand(sshCmd)
}

View File

@ -123,7 +123,6 @@ func init() {
exit.WithError("unable to bind flags", err)
}
RootCmd.AddCommand(startCmd)
}
// initMinikubeFlags includes commandline flags for minikube.

View File

@ -144,5 +144,4 @@ func init() {
statusCmd.Flags().StringVar(&statusFormat, "format", constants.DefaultStatusFormat,
`Go template format string for the status output. The format for Go templates can be found here: https://golang.org/pkg/text/template/
For the list accessible variables for the template, see the struct values here: https://godoc.org/k8s.io/minikube/cmd/minikube/cmd#Status`)
RootCmd.AddCommand(statusCmd)
}

View File

@ -81,7 +81,3 @@ func runStop(cmd *cobra.Command, args []string) {
exit.WithError("update config", err)
}
}
func init() {
RootCmd.AddCommand(stopCmd)
}

View File

@ -86,5 +86,4 @@ var tunnelCmd = &cobra.Command{
func init() {
tunnelCmd.Flags().BoolVarP(&cleanup, "cleanup", "c", false, "call with cleanup=true to remove old tunnels")
RootCmd.AddCommand(tunnelCmd)
}

View File

@ -48,7 +48,3 @@ var updateCheckCmd = &cobra.Command{
out.Ln("LatestVersion: %s", r[0].Name)
},
}
func init() {
RootCmd.AddCommand(updateCheckCmd)
}

View File

@ -56,7 +56,3 @@ var updateContextCmd = &cobra.Command{
},
}
func init() {
RootCmd.AddCommand(updateContextCmd)
}

View File

@ -38,7 +38,3 @@ var versionCmd = &cobra.Command{
}
},
}
func init() {
RootCmd.AddCommand(versionCmd)
}

1
go.mod
View File

@ -67,6 +67,7 @@ require (
k8s.io/api v0.0.0
k8s.io/apimachinery v0.0.0
k8s.io/client-go v0.0.0
k8s.io/kubectl v0.0.0-00010101000000-000000000000
k8s.io/kubernetes v1.15.0
sigs.k8s.io/sig-storage-lib-external-provisioner v4.0.0+incompatible
)

6
go.sum
View File

@ -10,6 +10,7 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/GoogleCloudPlatform/k8s-cloud-provider v0.0.0-20181220005116-f8e995905100/go.mod h1:iroGtC8B3tQiqtds1l+mgk/BBOrxbqjH+eUfFQYRc14=
github.com/JeffAshton/win_pdh v0.0.0-20161109143554-76bb4ee9f0ab/go.mod h1:3VYc5hodBMJ5+l/7J4xAyMeuM2PNuepvHlGs8yilUCA=
github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd h1:sjQovDkwrZp8u+gxLtPgKGjk5hCxuy2hrRejBTA9xFU=
github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd/go.mod h1:64YHyfSL2R96J44Nlwm39UHepQbyR5q10x7iYa1ks2E=
github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg=
@ -88,6 +89,7 @@ github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD
github.com/docker/libnetwork v0.0.0-20180830151422-a9cd636e3789/go.mod h1:93m0aTqz6z+g32wla4l4WxTrdtvBRmVzYRkYvasA5Z8=
github.com/docker/machine v0.16.1-0.20190718054102-a555e4f7a8f5 h1:5OiV/JwT55JRKNJsM9HZrTlJH/TRp97Ee89ahtB78+w=
github.com/docker/machine v0.16.1-0.20190718054102-a555e4f7a8f5/go.mod h1:I8mPNDeK1uH+JTcUU7X0ZW8KiYz0jyAgNaeSJ1rCfDI=
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 h1:cenwrSVm+Z7QLSV/BsnenAOcDXdX4cMv4wP0B/5QbPg=
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/elazarl/goproxy v0.0.0-20190421051319-9d40249d3c2f h1:8GDPb0tCY8LQ+OJ3dbHb5sA6YZWXFORQYZx5sdsTlMs=
@ -260,6 +262,8 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk
github.com/mitchellh/go-ps v0.0.0-20170309133038-4fdf99ab2936 h1:kw1v0NlnN+GZcU8Ma8CLF2Zzgjfx95gs3/GN3vYAPpo=
github.com/mitchellh/go-ps v0.0.0-20170309133038-4fdf99ab2936/go.mod h1:r1VsdOzOPt1ZSrGZWFoNhsAedKnEd6r9Np1+5blZCWk=
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4=
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/moby/hyperkit v0.0.0-20171020124204-a12cd7250bcd h1:WDG9l//UGcGx4lqqEDY23+mRnQMKFY+8LD83OxQllRk=
@ -517,6 +521,8 @@ k8s.io/kubernetes/staging/src/k8s.io/kube-aggregator v0.0.0-20190623232353-8c3b7
k8s.io/kubernetes/staging/src/k8s.io/kube-controller-manager v0.0.0-20190623232353-8c3b7d7679cc/go.mod h1:o6aAFW1lCnr5CJm1riWnhQskrAHhyt8btyv5UHhgZ6c=
k8s.io/kubernetes/staging/src/k8s.io/kube-proxy v0.0.0-20190623232353-8c3b7d7679cc/go.mod h1:y0hpsQGN8h3HcNqYbpSZEH4yC1ohi45N35c8ma9yg6M=
k8s.io/kubernetes/staging/src/k8s.io/kube-scheduler v0.0.0-20190623232353-8c3b7d7679cc/go.mod h1:/hbCTKdfutEO2iTQv8NuYcnAxd8Tuu4mMEymYv/EZHk=
k8s.io/kubernetes/staging/src/k8s.io/kubectl v0.0.0-20190623232353-8c3b7d7679cc h1:Bsljf/3UDy91qqLkevAiq6y+wl0qJrkLjWfBCQs9rss=
k8s.io/kubernetes/staging/src/k8s.io/kubectl v0.0.0-20190623232353-8c3b7d7679cc/go.mod h1:Vg6Q3IDU3hfYMICKyb43lClOXWtCtOBh2o1FfuQw8mQ=
k8s.io/kubernetes/staging/src/k8s.io/kubelet v0.0.0-20190623232353-8c3b7d7679cc/go.mod h1:9UInPlSttlDwZBFNMAsqhTtl7zH00dE2M88B9Z0Ennc=
k8s.io/kubernetes/staging/src/k8s.io/legacy-cloud-providers v0.0.0-20190623232353-8c3b7d7679cc/go.mod h1:xlTRb77uaXbuT6evILwFescWPMENFKYGYj3a/kOjYQE=
k8s.io/kubernetes/staging/src/k8s.io/metrics v0.0.0-20190623232353-8c3b7d7679cc/go.mod h1:6Cs3k9ccbWbJo3CQOrGDu2QEVLwsWbBlu9HitjPhuSk=