Skip to content

Commit

Permalink
Merge pull request kubernetes#4664 from eparis/kubectl-man
Browse files Browse the repository at this point in the history
kubectl autogen docs update
  • Loading branch information
vmarmol committed Feb 20, 2015
2 parents a17517f + 4806160 commit 54ef88b
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 66 deletions.
2 changes: 1 addition & 1 deletion Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Godeps/_workspace/src/github.com/spf13/cobra/cobra_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 71 additions & 3 deletions Godeps/_workspace/src/github.com/spf13/cobra/command.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 2 additions & 34 deletions cmd/gendocs/gen_kubectl_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,10 @@ import (

"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

func mergeFlags(old, newFlags *pflag.FlagSet) *pflag.FlagSet {
newFlags.VisitAll(func(f *pflag.Flag) {
if old.Lookup(f.Name) == nil {
old.AddFlag(f)
}
})
return old
}

func parentFlags(c *cobra.Command) *pflag.FlagSet {
if !c.HasParent() {
return pflag.NewFlagSet("empty", pflag.ExitOnError)
}
return mergeFlags(c.Parent().PersistentFlags(), parentFlags(c.Parent()))
}

func myFlags(c *cobra.Command) *pflag.FlagSet {
myFlags := c.Flags()
parentFlags := parentFlags(c)

if c.HasPersistentFlags() {
c.PersistentFlags().VisitAll(func(f *pflag.Flag) {
if c.Flags().Lookup(f.Name) == nil &&
parentFlags.Lookup(f.Name) == nil {
myFlags.AddFlag(f)
}
})
}
return myFlags
}

func printOptions(out *bytes.Buffer, command *cobra.Command, name string) {
flags := myFlags(command)
flags := command.NonInheritedFlags()
flags.SetOutput(out)
if command.Runnable() {
fmt.Fprintf(out, "%s\n\n", command.UseLine())
Expand All @@ -72,7 +40,7 @@ func printOptions(out *bytes.Buffer, command *cobra.Command, name string) {
fmt.Fprintf(out, "```\n\n")
}

parentFlags := parentFlags(command)
parentFlags := command.InheritedFlags()
parentFlags.SetOutput(out)
if parentFlags.HasFlags() {
fmt.Fprintf(out, "### Options inherrited from parent commands\n\n```\n")
Expand Down
9 changes: 0 additions & 9 deletions docs/kubectl-config-set-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ Sets a cluster entry in .kubeconfig

kubectl config set-cluster name [--server=server] [--certificate-authority=path/to/certficate/authority] [--api-version=apiversion] [--insecure-skip-tls-verify=true]

### Options

```
--api-version=: api-version for the cluster entry in .kubeconfig
--certificate-authority=: certificate-authority for the cluster entry in .kubeconfig
--insecure-skip-tls-verify=false: insecure-skip-tls-verify for the cluster entry in .kubeconfig
--server=: server for the cluster entry in .kubeconfig
```

### Options inherrited from parent commands

```
Expand Down
8 changes: 0 additions & 8 deletions docs/kubectl-config-set-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ Sets a context entry in .kubeconfig

kubectl config set-context name [--cluster=cluster-nickname] [--user=user-nickname] [--namespace=namespace]

### Options

```
--cluster=: cluster for the context entry in .kubeconfig
--namespace=: namespace for the context entry in .kubeconfig
--user=: user for the context entry in .kubeconfig
```

### Options inherrited from parent commands

```
Expand Down
11 changes: 0 additions & 11 deletions docs/kubectl-config-set-credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,6 @@ Sets a user entry in .kubeconfig

kubectl config set-credentials name [--auth-path=authfile] [--client-certificate=certfile] [--client-key=keyfile] [--token=bearer_token] [--username=basic_user] [--password=basic_password]

### Options

```
--auth-path=: auth-path for the user entry in .kubeconfig
--client-certificate=: client-certificate for the user entry in .kubeconfig
--client-key=: client-key for the user entry in .kubeconfig
--password=: password for the user entry in .kubeconfig
--token=: token for the user entry in .kubeconfig
--username=: username for the user entry in .kubeconfig
```

### Options inherrited from parent commands

```
Expand Down

0 comments on commit 54ef88b

Please sign in to comment.