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.
This commit is contained in:
Eric Paris
2015-02-20 16:28:43 -05:00
parent 781ca91a59
commit d508395828
15 changed files with 231 additions and 211 deletions

View File

@@ -30,36 +30,38 @@ import (
"github.com/spf13/cobra"
)
// NewCmdGet creates a command object for the generic "get" action, which
// retrieves one or more resources from a server.
func (f *Factory) NewCmdGet(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "get [(-o|--output=)json|yaml|template|...] <resource> [<id>]",
Short: "Display one or many resources",
Long: `Display one or many resources.
const (
get_long = `Display one or many resources.
Possible resources include pods (po), replication controllers (rc), services
(se), minions (mi), or events (ev).
By specifying the output as 'template' and providing a Go template as the value
of the --template flag, you can filter the attributes of the fetched resource(s).
of the --template flag, you can filter the attributes of the fetched resource(s).`
get_example = `// List all pods in ps output format.
$ kubectl get pods
Examples:
// List a single replication controller with specified ID in ps output format.
$ kubectl get replicationController 1234-56-7890-234234-456456
// List all pods in ps output format.
$ kubectl get pods
// List a single pod in JSON output format.
$ kubectl get -o json pod 1234-56-7890-234234-456456
// List a single replication controller with specified ID in ps output format.
$ kubectl get replicationController 1234-56-7890-234234-456456
// Return only the status value of the specified pod.
$ kubectl get -o template pod 1234-56-7890-234234-456456 --template={{.currentState.status}}
// List a single pod in JSON output format.
$ kubectl get -o json pod 1234-56-7890-234234-456456
// List all replication controllers and services together in ps output format.
$ kubectl get rc,services`
)
// Return only the status value of the specified pod.
$ kubectl get -o template pod 1234-56-7890-234234-456456 --template={{.currentState.status}}
// List all replication controllers and services together in ps output format.
$ kubectl get rc,services`,
// NewCmdGet creates a command object for the generic "get" action, which
// retrieves one or more resources from a server.
func (f *Factory) NewCmdGet(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "get [(-o|--output=)json|yaml|template|...] <resource> [<id>]",
Short: "Display one or many resources",
Long: get_long,
Example: get_example,
Run: func(cmd *cobra.Command, args []string) {
RunGet(f, out, cmd, args)
},