From d508395828e41d16722dc47f2f8fef264119dc1a Mon Sep 17 00:00:00 2001 From: Eric Paris Date: Fri, 20 Feb 2015 16:28:43 -0500 Subject: [PATCH] Change all cobra commands to use the example section This will output the examples in their own section, rather than as part of the 'long' synposis. --- pkg/kubectl/cmd/config/create_context.go | 3 +- pkg/kubectl/cmd/config/view.go | 11 +++--- pkg/kubectl/cmd/create.go | 28 ++++++++------- pkg/kubectl/cmd/delete.go | 45 ++++++++++++------------ pkg/kubectl/cmd/exec.go | 22 ++++++------ pkg/kubectl/cmd/expose.go | 25 +++++++------ pkg/kubectl/cmd/get.go | 42 +++++++++++----------- pkg/kubectl/cmd/label.go | 39 ++++++++++---------- pkg/kubectl/cmd/log.go | 23 ++++++------ pkg/kubectl/cmd/portforward.go | 35 +++++++++--------- pkg/kubectl/cmd/resize.go | 26 +++++++------- pkg/kubectl/cmd/rollingupdate.go | 35 +++++++++--------- pkg/kubectl/cmd/run.go | 38 ++++++++++---------- pkg/kubectl/cmd/stop.go | 36 ++++++++++--------- pkg/kubectl/cmd/update.go | 34 +++++++++--------- 15 files changed, 231 insertions(+), 211 deletions(-) diff --git a/pkg/kubectl/cmd/config/create_context.go b/pkg/kubectl/cmd/config/create_context.go index 2da9b859c91..aac3d588a26 100644 --- a/pkg/kubectl/cmd/config/create_context.go +++ b/pkg/kubectl/cmd/config/create_context.go @@ -46,8 +46,7 @@ func NewCmdConfigSetContext(out io.Writer, pathOptions *pathOptions) *cobra.Comm Specifying a name that already exists will merge new fields on top of existing values for those fields. e.g. kubectl config set-context gce --user=cluster-admin - only sets the user field on the gce context entry without touching other values. - `, + only sets the user field on the gce context entry without touching other values.`, Run: func(cmd *cobra.Command, args []string) { if !options.complete(cmd) { diff --git a/pkg/kubectl/cmd/config/view.go b/pkg/kubectl/cmd/config/view.go index 95f13c6dcc6..434cc2c9b3d 100644 --- a/pkg/kubectl/cmd/config/view.go +++ b/pkg/kubectl/cmd/config/view.go @@ -41,13 +41,12 @@ func NewCmdConfigView(out io.Writer, pathOptions *pathOptions) *cobra.Command { cmd := &cobra.Command{ Use: "view", Short: "displays merged .kubeconfig settings or a specified .kubeconfig file.", - Long: `displays merged .kubeconfig settings or a specified .kubeconfig file. -Examples: - // Show merged .kubeconfig settings. - $ kubectl config view + Long: "displays merged .kubeconfig settings or a specified .kubeconfig file.", + Example: `// Show merged .kubeconfig settings. +$ kubectl config view - // Show only local ./.kubeconfig settings - $ kubectl config view --local`, +// Show only local ./.kubeconfig settings +$ kubectl config view --local`, Run: func(cmd *cobra.Command, args []string) { options.complete() diff --git a/pkg/kubectl/cmd/create.go b/pkg/kubectl/cmd/create.go index 67098970c45..187e6b0dc26 100644 --- a/pkg/kubectl/cmd/create.go +++ b/pkg/kubectl/cmd/create.go @@ -26,24 +26,26 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/util" ) +const ( + create_long = `Create a resource by filename or stdin. + +JSON and YAML formats are accepted.` + create_example = `// Create a pod using the data in pod.json. +$ kubectl create -f pod.json + +// Create a pod based on the JSON passed into stdin. +$ cat pod.json | kubectl create -f -` +) + func (f *Factory) NewCmdCreate(out io.Writer) *cobra.Command { flags := &struct { Filenames util.StringList }{} cmd := &cobra.Command{ - Use: "create -f filename", - Short: "Create a resource by filename or stdin", - Long: `Create a resource by filename or stdin. - -JSON and YAML formats are accepted. - -Examples: - - // Create a pod using the data in pod.json. - $ kubectl create -f pod.json - - // Create a pod based on the JSON passed into stdin. - $ cat pod.json | kubectl create -f -`, + Use: "create -f filename", + Short: "Create a resource by filename or stdin", + Long: create_long, + Example: create_example, Run: func(cmd *cobra.Command, args []string) { schema, err := f.Validator(cmd) checkErr(err) diff --git a/pkg/kubectl/cmd/delete.go b/pkg/kubectl/cmd/delete.go index bd3777f454a..8797ab24648 100644 --- a/pkg/kubectl/cmd/delete.go +++ b/pkg/kubectl/cmd/delete.go @@ -28,14 +28,8 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/util" ) -func (f *Factory) NewCmdDelete(out io.Writer) *cobra.Command { - flags := &struct { - Filenames util.StringList - }{} - cmd := &cobra.Command{ - Use: "delete ([-f filename] | ( [( | -l