Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
//Copyright 2015 Red Hat Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2015-11-23 23:19:16 +00:00
|
|
|
package doc
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2015-11-23 23:19:16 +00:00
|
|
|
"io"
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
"os"
|
2016-01-17 00:24:54 +00:00
|
|
|
"path/filepath"
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
"sort"
|
|
|
|
"strings"
|
|
|
|
"time"
|
2015-11-23 23:19:16 +00:00
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
)
|
|
|
|
|
2016-01-06 10:59:28 +00:00
|
|
|
func printOptions(w io.Writer, cmd *cobra.Command, name string) error {
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
flags := cmd.NonInheritedFlags()
|
2016-01-06 10:59:28 +00:00
|
|
|
flags.SetOutput(w)
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
if flags.HasFlags() {
|
2016-01-06 10:59:28 +00:00
|
|
|
if _, err := fmt.Fprintf(w, "### Options\n\n```\n"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
flags.PrintDefaults()
|
2016-01-06 10:59:28 +00:00
|
|
|
if _, err := fmt.Fprintf(w, "```\n\n"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
parentFlags := cmd.InheritedFlags()
|
2016-01-06 10:59:28 +00:00
|
|
|
parentFlags.SetOutput(w)
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
if parentFlags.HasFlags() {
|
2016-01-06 10:59:28 +00:00
|
|
|
if _, err := fmt.Fprintf(w, "### Options inherited from parent commands\n\n```\n"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
parentFlags.PrintDefaults()
|
2016-01-06 10:59:28 +00:00
|
|
|
if _, err := fmt.Fprintf(w, "```\n\n"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
}
|
2016-01-06 10:59:28 +00:00
|
|
|
return nil
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
}
|
|
|
|
|
2016-01-06 10:59:28 +00:00
|
|
|
func GenMarkdown(cmd *cobra.Command, w io.Writer) error {
|
|
|
|
return GenMarkdownCustom(cmd, w, func(s string) string { return s })
|
2015-05-13 09:27:18 +00:00
|
|
|
}
|
|
|
|
|
2016-01-06 10:59:28 +00:00
|
|
|
func GenMarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string) string) error {
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
name := cmd.CommandPath()
|
|
|
|
|
|
|
|
short := cmd.Short
|
|
|
|
long := cmd.Long
|
|
|
|
if len(long) == 0 {
|
|
|
|
long = short
|
|
|
|
}
|
|
|
|
|
2016-01-06 10:59:28 +00:00
|
|
|
if _, err := fmt.Fprintf(w, "## %s\n\n", name); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := fmt.Fprintf(w, "%s\n\n", short); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := fmt.Fprintf(w, "### Synopsis\n\n"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := fmt.Fprintf(w, "\n%s\n\n", long); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
|
|
|
|
if cmd.Runnable() {
|
2016-01-06 10:59:28 +00:00
|
|
|
if _, err := fmt.Fprintf(w, "```\n%s\n```\n\n", cmd.UseLine()); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(cmd.Example) > 0 {
|
2016-01-06 10:59:28 +00:00
|
|
|
if _, err := fmt.Fprintf(w, "### Examples\n\n"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := fmt.Fprintf(w, "```\n%s\n```\n\n", cmd.Example); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
}
|
|
|
|
|
2016-01-06 10:59:28 +00:00
|
|
|
if err := printOptions(w, cmd, name); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2015-11-23 23:19:16 +00:00
|
|
|
if hasSeeAlso(cmd) {
|
2016-01-06 10:59:28 +00:00
|
|
|
if _, err := fmt.Fprintf(w, "### SEE ALSO\n"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
if cmd.HasParent() {
|
|
|
|
parent := cmd.Parent()
|
|
|
|
pname := parent.CommandPath()
|
|
|
|
link := pname + ".md"
|
|
|
|
link = strings.Replace(link, " ", "_", -1)
|
2016-01-06 10:59:28 +00:00
|
|
|
if _, err := fmt.Fprintf(w, "* [%s](%s)\t - %s\n", pname, linkHandler(link), parent.Short); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2015-11-23 23:19:16 +00:00
|
|
|
cmd.VisitParents(func(c *cobra.Command) {
|
2015-11-08 01:21:25 +00:00
|
|
|
if c.DisableAutoGenTag {
|
|
|
|
cmd.DisableAutoGenTag = c.DisableAutoGenTag
|
|
|
|
}
|
|
|
|
})
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
children := cmd.Commands()
|
|
|
|
sort.Sort(byName(children))
|
|
|
|
|
|
|
|
for _, child := range children {
|
2017-03-09 15:37:15 +00:00
|
|
|
if !child.IsAvailableCommand() || child.IsAdditionalHelpTopicCommand() {
|
2015-04-07 21:38:22 +00:00
|
|
|
continue
|
|
|
|
}
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
cname := name + " " + child.Name()
|
|
|
|
link := cname + ".md"
|
|
|
|
link = strings.Replace(link, " ", "_", -1)
|
2016-01-06 10:59:28 +00:00
|
|
|
if _, err := fmt.Fprintf(w, "* [%s](%s)\t - %s\n", cname, linkHandler(link), child.Short); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if _, err := fmt.Fprintf(w, "\n"); err != nil {
|
|
|
|
return err
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-08 01:21:25 +00:00
|
|
|
if !cmd.DisableAutoGenTag {
|
2016-01-06 10:59:28 +00:00
|
|
|
if _, err := fmt.Fprintf(w, "###### Auto generated by spf13/cobra on %s\n", time.Now().Format("2-Jan-2006")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2015-11-08 01:21:25 +00:00
|
|
|
}
|
2016-01-06 10:59:28 +00:00
|
|
|
return nil
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
}
|
|
|
|
|
2016-01-06 10:59:28 +00:00
|
|
|
func GenMarkdownTree(cmd *cobra.Command, dir string) error {
|
2015-05-21 00:21:00 +00:00
|
|
|
identity := func(s string) string { return s }
|
|
|
|
emptyStr := func(s string) string { return "" }
|
2016-01-06 10:59:28 +00:00
|
|
|
return GenMarkdownTreeCustom(cmd, dir, emptyStr, identity)
|
2015-08-18 22:33:41 +00:00
|
|
|
}
|
|
|
|
|
2016-01-06 10:59:28 +00:00
|
|
|
func GenMarkdownTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string) error {
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
for _, c := range cmd.Commands() {
|
2017-03-09 15:37:15 +00:00
|
|
|
if !c.IsAvailableCommand() || c.IsAdditionalHelpTopicCommand() {
|
2015-08-18 22:33:41 +00:00
|
|
|
continue
|
|
|
|
}
|
2016-01-06 10:59:28 +00:00
|
|
|
if err := GenMarkdownTreeCustom(c, dir, filePrepender, linkHandler); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
}
|
|
|
|
|
2016-01-17 00:24:54 +00:00
|
|
|
basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".md"
|
|
|
|
filename := filepath.Join(dir, basename)
|
2016-01-06 10:59:28 +00:00
|
|
|
f, err := os.Create(filename)
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
if err != nil {
|
2016-01-06 10:59:28 +00:00
|
|
|
return err
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
}
|
2016-01-06 10:59:28 +00:00
|
|
|
defer f.Close()
|
|
|
|
|
|
|
|
if _, err := io.WriteString(f, filePrepender(filename)); err != nil {
|
|
|
|
return err
|
2015-05-13 09:27:18 +00:00
|
|
|
}
|
2016-01-06 10:59:28 +00:00
|
|
|
if err := GenMarkdownCustom(cmd, f, linkHandler); err != nil {
|
|
|
|
return err
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
}
|
2016-01-06 10:59:28 +00:00
|
|
|
return nil
|
Auto generation of markdown docs!
An example from the kubernetes project, for the `kubectl config`
command, which as subcommands, and flags, and all sorts of stuff, it
will generate markdown like so:
config modifies .kubeconfig files
config modifies .kubeconfig files using subcommands like "kubectl config set current-context my-context"
```
kubectl config SUBCOMMAND
```
```
--envvar=false: use the .kubeconfig from $KUBECONFIG
--global=false: use the .kubeconfig from /home/username
-h, --help=false: help for config
--kubeconfig="": use a particular .kubeconfig file
--local=false: use the .kubeconfig in the current directory
```
```
--alsologtostderr=false: log to standard error as well as files
--api-version="": The API version to use when talking to the server
-a, --auth-path="": Path to the auth info file. If missing, prompt the user. Only used if using https.
--certificate-authority="": Path to a cert. file for the certificate authority.
--client-certificate="": Path to a client key file for TLS.
--client-key="": Path to a client key file for TLS.
--cluster="": The name of the kubeconfig cluster to use
--context="": The name of the kubeconfig context to use
--insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir=: If non-empty, write log files in this directory
--log_flush_frequency=5s: Maximum number of seconds between log flushes
--logtostderr=true: log to standard error instead of files
--match-server-version=false: Require server version to match client version
--namespace="": If present, the namespace scope for this CLI request.
--password="": Password for basic authentication to the API server.
-s, --server="": The address and port of the Kubernetes API server
--stderrthreshold=2: logs at or above this threshold go to stderr
--token="": Bearer token for authentication to the API server.
--user="": The name of the kubeconfig user to use
--username="": Username for basic authentication to the API server.
--v=0: log level for V logs
--validate=false: If true, use a schema to validate the input before sending it
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
* [kubectl config set](kubectl_config_set.md) - Sets an individual value in a .kubeconfig file
* [kubectl config set-cluster](kubectl_config_set-cluster.md) - Sets a cluster entry in .kubeconfig
* [kubectl config set-context](kubectl_config_set-context.md) - Sets a context entry in .kubeconfig
* [kubectl config set-credentials](kubectl_config_set-credentials.md) - Sets a user entry in .kubeconfig
* [kubectl config unset](kubectl_config_unset.md) - Unsets an individual value in a .kubeconfig file
* [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a .kubeconfig file
* [kubectl config view](kubectl_config_view.md) - displays merged .kubeconfig settings or a specified .kubeconfig file.
2015-04-07 03:38:51 +00:00
|
|
|
}
|