Commit Graph

1066 Commits

Author SHA1 Message Date
Albert Nigmatzianov 99838a52fe cmd: Small fixes 2017-07-31 06:38:19 -06:00
bpicode d7ba19510d Add basic zsh completion (command hierarchy only)
Partially fixes #107
See PR #497
2017-07-30 02:44:28 -06:00
Anthony Fok 9e024b655b cmd: Refine formatting of included licenses 2017-07-30 02:35:06 -06:00
Anthony Fok a1b7d3cc4d cmd: Add a blank line between copyright and license 2017-07-30 02:15:55 -06:00
Anthony Fok 75c6acfc8f cmd: Add "-u" to output unified diff in golden tests 2017-07-30 02:11:56 -06:00
Anthony Fok cb9cf94690 Restore the use of cobra.OnInitialize in cobra executable
Without cobra.OnInitialize, cobra does not see the --config
command-line option and always tries to load $HOME/.cobra.yaml
instead.
2017-07-30 01:19:17 -06:00
Anthony Fok d4c40bbacf travis: Update Go versions 2017-07-30 00:20:54 -06:00
Anthony Fok 750ba8ac93 Fix reproducibility in TestGolden{Add,Init}Cmd
These tests were time-dependent and would start failing in 2018
when the golden files still have the copyright year of 2017.

Fix by hard-coding the year 2017 for the purpose of these two tests
to ensure reproducible builds.

Fixes #503
2017-07-30 00:17:45 -06:00
Anthony Fok 161584fc2e Fix minor typos: "Know" → "Known" 2017-07-29 22:49:33 -06:00
Anthony Fok 34594c771f Fix TestGlobalNormFuncPropagation() on gccgo
According to golang/go#9504 and https://golang.org/pkg/reflect/#Value,
== should not be used on two reflect.Values, but comparing the results
of their Interface() method does not work in this case, so let's
compare the results of their Pointer() method instead.

See https://stackoverflow.com/questions/9643205/how-do-i-compare-two-functions-for-pointer-equality-in-the-latest-go-weekly
2017-07-25 14:04:38 +02:00
Albert Nigmatzianov 90fc11bbc0 Update README.md 2017-07-24 09:18:37 +02:00
Daniel Nephin f20b4e9c32 Refactor TakesArgs to use an interface for arg validation.
Fix some typos in README and comments.
Move arg validation to after flag validation so that the help flag is run first.
Pass the same args to ValidateArgs as the Run methods receive.
Update README.

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-07-23 09:57:27 +02:00
Eric Paris d89c499964 Allow commands to explicitly state if they do, or do not take arbitrary arguments
Check that arguments are in ValidArgs

If a command defined cmd.ValidArgs check that the argument is actually
in ValidArgs and fail if it is not.
2017-07-23 09:57:27 +02:00
Albert Nigmatzianov 715f41bd7a cmd: Ignore hidden files in isEmpty 2017-07-18 18:22:37 +02:00
Albert Nigmatzianov d994347eda Delete tab in the long description of help 2017-07-16 12:48:02 +02:00
Albert Nigmatzianov c46add8a65 Add ability to disable mousetrap
Fix #486
Close #383 (no progress there)
2017-07-11 14:08:33 +02:00
Albert Nigmatzianov 8c6fa02d22 Fix InitDefaultHelpCmd when custom help command is set 2017-06-29 12:52:34 +02:00
Johanan Liebermann 4d647c8944 Print err instead of home
When 'home' can't be determined it doesn't make sense to print it.
The value of 'err' should be printed instead.
2017-06-24 17:01:00 +02:00
Johanan Liebermann 6471e3de04 Rename main func to initConfig
The function called `main` in the manual creation example should be called
`initConfig`.
2017-06-24 16:56:34 +02:00
Johanan Liebermann f9d34972c1 Fix RootCmd var name
'rootCmd' should be 'RootCmd'.
2017-06-24 16:56:22 +02:00
Johanan Lieberman d638dcb7c7 Improve readability of README
Improve punctuation, fix capitalization in a couple of places and
rephrase some sentences for better readability.
2017-06-23 19:56:08 +02:00
Brian Danowski e458bb7ab8 Reword `become unexpected errors` to `encounter errors` 2017-06-23 16:17:13 +02:00
Johanan Liebermann 31694f19ad Add missing 'and' in comment 2017-06-21 19:32:59 +02:00
Albert Nigmatzianov 99b5d838ca Show messages if deprecated flags are used
Fix #463
2017-06-19 23:05:29 +02:00
Albert Nigmatzianov b4dbd37a01 cmd: Fix tests 2017-06-12 08:36:10 +02:00
Albert Nigmatzianov defa97f560 cmd: Fix output root.go of init with --viper=false
Fix #462
2017-06-12 08:23:33 +02:00
Albert Nigmatzianov d7cfb13474 Update README.md 2017-06-09 21:55:21 +02:00
Albert Nigmatzianov 99ff9334bd cmd: Add possibility to specify the target package
Fix #455
2017-06-07 08:07:48 +02:00
Albert Nigmatzianov 84f471618b Make BenchmarkBashCompletion more honest
name              old time/op    new time/op    delta
BashCompletion-4    67.4µs ± 1%    50.8µs ± 3%  -24.63%  (p=0.000 n=17+19)

name              old alloc/op   new alloc/op   delta
BashCompletion-4    29.5kB ± 0%    29.5kB ± 0%   +0.00%  (p=0.020 n=20+20)

name              old allocs/op  new allocs/op  delta
BashCompletion-4       253 ± 0%       253 ± 0%     ~     (all equal)
2017-06-05 19:32:33 +02:00
Lucy Davies 66da711334 __ltrim_colon_completions is not always available on macOS (#459)
* __ltrim_colon_completions is not always available on macOS, so bash-completion should check first
2017-06-05 11:18:07 -04:00
Martin Marcher 8d4ce3549a Update README.md
Fix description to actually install generator as well as latest version of the library
2017-05-31 06:54:52 +02:00
Albert Nigmatzianov e606913c4e Fix typos 2017-05-28 12:56:30 +02:00
Albert Nigmatzianov 4a1a7b086e cmd: Don't print errors from execute to prevent duplication of errors 2017-05-28 12:26:28 +02:00
Albert Nigmatzianov c446db21d3 cmd: Delete projectBase flag
It's redundant and it didn't work earlier anyway.
2017-05-28 12:25:51 +02:00
Albert Nigmatzianov 7918bf6886 Add explanation for viper.BindPflag in README.md
Fix #429

/cc @deltaskelta
2017-05-28 09:16:21 +02:00
Albert Nigmatzianov ca57f0f5db doc: Ad help flag and cmd when generating docs 2017-05-20 19:28:06 +02:00
Albert Nigmatzianov 52ae6a1d02 Make initHelpCmd public (#436)
Useful for solving #424
2017-05-20 19:23:33 +02:00
Albert Nigmatzianov ca5710c94e Fix link to cobra lib in README.md 2017-05-19 22:27:40 +02:00
Robert Anthony Bellamy 4ba54a0f7f Edit installation command in README.md (#451) 2017-05-19 21:09:26 +02:00
Albert Nigmatzianov fb1f39915d Add benchmark for GenBashCompletion 2017-05-18 15:03:00 +02:00
Albert Nigmatzianov de6b168d98 Simplify bash_completions.go
Improve test coverage from 80% to 85%.
2017-05-18 15:03:00 +02:00
Albert Nigmatzianov 4cdb38c072 cmd: Use correct HasPrefix function for paths
Updates #448
2017-05-15 09:51:20 +02:00
Albert Nigmatzianov e9078fccb8 cmd: Make more accurate error when there is no $GOPATH 2017-05-15 09:20:36 +02:00
Albert Nigmatzianov fa9ac853ce cmd: Make detailed error when project not in $GOPATH
Updates #448
2017-05-15 08:37:15 +02:00
Albert Nigmatzianov 51b7cf57e1 Fix tests so they give correct args (#445)
* Fix tests so they give correct args

Shell already deletes all quotes and unite args under quotes, so we
don't need to test it.

* Simplify stripFlags

* Fix 'unused' and 'gosimple' complaints
2017-05-14 08:51:04 -04:00
Albert Nigmatzianov b5366273a6 cmd: Fix some gometalinter complaints 2017-05-14 12:27:15 +02:00
Albert Nigmatzianov d9414968f8 cmd: Fix error message from go-homedir 2017-05-14 12:03:16 +02:00
Behrang Noruzi Niya a28055bed2 cmd: Fix minor bugs in init command (#446) 2017-05-14 12:00:53 +02:00
Don Petersen 90687e7bfc Update pflag link in README (#444)
Cobra is not using ogier/pflag, but a fork of it.
2017-05-12 20:40:24 +02:00
Albert Nigmatzianov 7d22e77cce Fix incorrect merge of pflag.CommandLine to cmd.Flags()
Fix #443
2017-05-12 20:22:26 +02:00