Commit graph

375 commits

Author SHA1 Message Date
Eric Paris
d0bb3e33e6 rework Find() to make it more obvious what is happening
We had lots of quirky if statements like `commandFound.Name() ==
c.Name() && len(stripFlags(args, c)) > 0 && commandFound.Name() !=
args[0]` which embeed all sorts of artifacts which are hard to parse. So
in general, just try to simplify and make stuff readable.
2015-06-29 15:44:56 -04:00
Eric Paris
66816bcd03 Merge pull request #119 from eparis/bogus-bad-command
Handle grand children with the same name as the root
2015-06-22 17:06:05 -05:00
Eric Paris
07ad27d239 Handle grand children with the same name as the root
This fixes a problem where if you had a root command and a grand child
with the same name, the parser would break and would not run the
grandchild. The code was special casing if the immediate child had the
same name, but didn't handle grand-children
2015-06-22 17:54:08 -04:00
Eric Paris
ddd4c82b82 Merge pull request #116 from sgotti/fix_flag_as_unknown_command_in_output
Correctly print the unknown command name
2015-06-22 16:52:47 -05:00
Eric Paris
a8f7f3dc25 Merge pull request #118 from liggitt/file_autocomplete_helper
Simplify setting file/extension annotations on a flag
2015-06-22 14:56:13 -05:00
Jordan Liggitt
6119fc993e Simplify setting file/extension annotations on a flag 2015-06-22 15:16:00 -04:00
Simone Gotti
fb86c5c559 Correctly print the unknown command name
by now, if someone calls: `program --validflag unknowncommand` the
output will be:

```
Error: unknown command "--validflag"
Run 'program help' for usage.
```

This patch strips out flags so the unknown command is printed:

```
Error: unknown command "unknowncommand"
Run 'program help' for usage.
```
2015-06-22 11:02:06 +02:00
Bjørn Erik Pedersen
312092086b Merge pull request #115 from skonzem/fix_typos
Fix typos in docs
2015-06-05 20:08:24 +02:00
Scott Konzem
39e648c2b0 Fix typos in docs 2015-06-05 13:02:54 -04:00
Eric Paris
8f5946caae Merge pull request #112 from jlowdermilk/fix-genmarkdowntree
Don't prepend filename in default GenMarkdownTree
2015-05-20 22:43:41 -05:00
Jeff Lowdermilk
7b4b4aaac9 Don't prepend filename in default GenMarkdownTree 2015-05-20 17:21:00 -07:00
Anastasis Andronidis
d910a04b50 Add Global Normalization Function
[close #110]
2015-05-19 10:23:16 -04:00
Sam Ghods
e0f326dabc Fix root command without subcommands but with arguments
[close #108]
2015-05-19 10:22:07 -04:00
Eric Paris
c11766b405 slight typo in md_docs.md 2015-05-13 08:38:33 -05:00
Bjørn Erik Pedersen
e659faf634 Merge pull request #109 from bep/markdowncustom
genmarkdown: add optional frontmatter- and linkadjustment-funcs
2015-05-13 15:30:04 +02:00
bep
1d99c8ff6d genmarkdown: add optional frontmatter- and linkadjustment-funcs
The automatic Markdown generator works great!

But to use it to render the documentation in Hugo, we need front matter and slightly different links.

This commit adds optional callback funcs to add that.
2015-05-13 15:22:00 +02:00
bep
be18870136 Fix two failing tests
The error message has changed ever so slightly.
2015-05-13 11:54:47 +02:00
Eric Paris
bba56042cf Merge pull request #105 from eparis/minor-bash-cleanup
make filename extension handling a bash function
2015-05-04 22:51:16 -05:00
Eric Paris
dff410ab56 make filename extension handling a bash function
We were trying to call a bash function with bash stuff like @ () from a
variable.  Stop that.  Just call a function with an arg from a variable
instead of trying to pass around the bash.

Should fix https://github.com/spf13/cobra/pull/103
2015-05-04 18:41:53 -04:00
Eric Paris
743fa31b46 Merge pull request #106 from eparis/bash-comp-docs
Make the filename extension bit of docs easier to read.
2015-05-04 15:20:46 -05:00
Eric Paris
48b95d0594 Make the filename extension bit of docs easier to read. 2015-05-04 16:20:06 -04:00
Eric Paris
787b737b48 Merge pull request #104 from eparis/minor-bash-cleanup
Clean up minor bash complaints from shellcheck.net
2015-05-04 13:56:05 -05:00
Eric Paris
f4b3401f9e Clean up minor bash complaints from shellcheck.net 2015-05-04 14:40:27 -04:00
Eric Paris
7fc9f148dd Merge pull request #102 from andronat/master
Fixed Persistent-Run function propagation
2015-05-04 11:57:28 -05:00
Anastasis Andronidis
799a8ef863 Test for Persistent-Run propagation 2015-05-04 17:57:46 +02:00
Anastasis Andronidis
42e6ce397f Fixed Persistent-Run function propagation 2015-05-04 03:42:55 +02:00
Eric Paris
3ee9552eeb Merge pull request #100 from eparis/pre-post-run
Pre post run fucntions
2015-04-30 13:26:01 -05:00
Eric Paris
fad5931693 Add docs, tests, and bit of rearrainging... 2015-04-30 14:08:47 -04:00
Alexander Thaller
fbce60cc56 added persistent pre/post commands. 2015-04-30 12:45:23 -04:00
Alexander Thaller
2df64026ba added pre and post run hooks. 2015-04-30 12:44:01 -04:00
Eric Paris
9cf0f3737d Merge pull request #90 from eparis/deprecated-subcommands
Deprecated subcommands
2015-04-30 10:22:48 -05:00
Eric Paris
7c7837e882 Merge pull request #85 from eparis/more-simplification
More simplification
2015-04-30 10:21:12 -05:00
Eric Paris
2d5fab043c Merge pull request #75 from eparis/CommandLine
Make flags declared outside spf13.pflag persistent flags on the parent
2015-04-30 10:20:35 -05:00
Eric Paris
c3e48f996d Deprecated subcommands
They should still work, but shouldn't show up in help or usage output
2015-04-29 13:08:20 -04:00
Eric Paris
69e5f196b5 Merge pull request #98 from eparis/markdown-quiet-test
quiet down to go test for markdown generation
2015-04-28 09:43:10 -05:00
Eric Paris
a112838e26 quiet down to go test for markdown generation
We were printing the markdown, don't ask me why.
2015-04-28 10:42:03 -04:00
Clayton Coleman
af6b555418 Merge pull request #95 from deads2k/deads-prevent-extra-removal
prevent removal of valid arguments
2015-04-28 10:06:27 -04:00
deads2k
36aee64abe prevent removal of valid arguments 2015-04-28 07:58:26 -04:00
Bjørn Erik Pedersen
ebb2d55f56 Merge pull request #97 from sdboyer/patch-1
Fix misspelling typo
2015-04-26 16:23:45 +02:00
Sam Boyer
476e73f093 Fix misspelling typo 2015-04-26 08:53:29 -04:00
Bjørn Erik Pedersen
d697cc29c1 Merge pull request #96 from commonlisp/master
Fixed typo in md output
2015-04-25 22:31:21 +02:00
George Kuan
c4667c9e63 Fixed typo in md output 2015-04-25 10:59:26 -07:00
Eric Paris
3c187e9045 Merge pull request #93 from kennyballou/minor_grammar_fix
Fix minor wording issue in README
2015-04-16 16:19:32 -05:00
kballou
f491ee284b Fix minor wording issue in README 2015-04-16 15:15:33 -06:00
Eric Paris
9cb5e85029 Merge pull request #92 from eparis/sort-valid-args
Sort the valid args before output
2015-04-13 17:59:01 -05:00
Eric Paris
0fc734c3c5 Sort the valid args before output
We do this so we get stable repeatable output and can see if updates are
necessary or if it is just golang doing the same thing twice differently
2015-04-13 18:44:05 -04:00
Eric Paris
c0da825198 Merge pull request #87 from eparis/gen-md-doc
Auto generation of markdown docs!
2015-04-12 13:45:33 -05:00
Eric Paris
8a18f25809 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-12 14:40:34 -04:00
Eric Paris
c746d30ef0 Merge pull request #69 from eparis/command-annotations
Bash Autocompletion Generator
2015-04-10 23:20:17 -05:00
Eric Paris
9ea4cdf081 Merge pull request #91 from PeterDaveHello/patch-1
Use svg instead of png to get better image quality
2015-04-10 23:20:05 -05:00