Commit graph

942 commits

Author SHA1 Message Date
Marc Khouzam
b80aeb17fc
Add support for custom completions in Go (#1035)
This commit allows programs using Cobra to code their custom completions
in Go instead of Bash.

The new ValidArgsFunction field is added for commands, similarly to
ValidArgs.  For flags, the new function
Command.RegisterFlagCompletionFunc() is added.

When either of the above functions is used, the bash completion script
will call the new hidden command '__complete', passing it all
command-line arguments. The '__complete' command will call
the function specified by Command.ValidArgsFunction or by
Command.RegisterFlagCompletionFunc to obtain completions from the
program itself.

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
2020-04-03 13:43:43 -06:00
John Calabrese
138b98f39d
add support for autolabel stale PR (#1075)
* add support for autolabel stale PR

automatically labels stale PRs

* stale label is kind/stale

updates the stale label to reflect
existing project labels

* adds a relevant stale message

for both PRs and issues there is now a more
descriptive and relevant message
when the action marks something stale

* no auto-close on stale issues/prs

uses the exempt flag to ignore issues already marked
stale. this will allow us to auto label stale,
and then ignore them so they do not get auto
closed.
2020-04-02 10:55:31 -06:00
John Calabrese
d88d9a09e9
Add Labeler Actions (#1074)
* adds labels to PRs

this will label PRs such that 
the maintainers have visibility into 
the breadth of the changes being suggested

* Create labeler.yml

* add all shell completions to labeler

any changes to and autocomplete for any shell
will now be auto labelled as impacting the autocompletion functionality
2020-04-02 09:26:08 -06:00
Joshua Harshman
bbffa3aa94
rm circle ci badge (#1073) 2020-04-01 10:27:47 -06:00
Kanji Yomoda
f62883520e
Replace deprecated SetOutput func with SetOut and SetErr in test (#1053) 2020-04-01 10:25:22 -06:00
Joshua Harshman
6607e6b860
Partial Revert of #922 (#1068)
Issue Reference: https://github.com/spf13/cobra/issues/1056

https://github.com/spf13/cobra/pull/922 introduced a new error
type that emitted when a command was not runnable. This caused
all commands w/o a run function set to error w/ that message and a status code of 1.

This change reverts the addition of that new error. Similar
functionality can be accomplished by leveraging RunE.
2020-03-27 14:38:32 -06:00
Dave Henderson
95f2f73ed9
Add short version flag -v when not otherwise set (#996)
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
2020-02-28 11:13:40 -07:00
Joshua Harshman
39cf99f556
leverage makefile to run build tasks (#976)
remove circle ci
2020-02-20 12:25:38 -07:00
Daniel Esponda
3c2624538b
Correct documentation for InOrStdin (#929)
Documentation on function is incorrect
2020-02-20 11:42:29 -07:00
Alexandr Burdiyan
0da0687426
Add support for context.Context 2020-02-20 07:29:50 +01:00
Andrea Falzetti
21cab29ef9
fix: undefined er (#1039) 2020-02-19 11:20:06 -05:00
Nickolas Kraus
89c7ffb512 Bump year on golden files (#1010) 2020-01-06 11:10:57 -07:00
Marc Khouzam
bf26895664 Fix regression when calling *_custom_func (#1001)
PR #889 introduced a regression where the global variable $c is no
longer set when *custom_func is called.  This is because $c is re-used
by mistake in the read loop.

This PR simply changes the name of the variable used in the loop.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
2019-12-26 10:55:42 -07:00
Joshua Harshman
447f182a9d
format tpl/main.go templates (#980) 2019-12-23 13:51:40 -07:00
Marc Khouzam
0d9d2d46f3 Revert change so help is printed on stdout again (#1004)
Fixes #1002
For backwards compatibility reasons, and to follow the need of
https://github.com/kubernetes/kubernetes/pull/26077#issuecomment-230818900
the help message should be printed on stdout.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
2019-12-23 13:38:24 -05:00
Stefano Guerrini
b04b5bfc50 substitute wrong word in md_docs (#998) 2019-12-02 08:04:30 -05:00
Peter Fern
77e4d5aecc Update md2man to v2.0.0 (#977)
Fixes #805
2019-10-19 16:17:41 -06:00
umarcor
8a4b46fadf update viper to v1.4.0 (#953) 2019-10-13 21:11:37 -06:00
XuZvvHYmZfYdWJNRunkJ
c022f6fabd Update README.md (#944)
I think it meant to be `Echo` here instead of `Print` since the command is called `cmdEcho`.
2019-10-07 15:41:51 -06:00
Joshua Harshman
48e6ac4718
update doc w/ newer cmd/root.go example (#973) 2019-10-07 15:31:10 -06:00
Joshua Harshman
3745fcd262
add goreportcard to readme (#971) 2019-10-03 15:53:10 -06:00
umarcor
19cf35ea77 fix: ensure that testproject is removed even after a failure (#948)
* fix: ensure that testproject is removed even after a failure

* fix: defer licenseFile

* style: simply defer os.RemoveAll

* cobra/cmd: add getProject test func
2019-09-17 09:02:42 -06:00
Christian Muehlhaeuser
606aa5792c Used goimports to fix import order (#912)
Keeps the list sorted and prevents future merge conflicts.
2019-09-16 20:17:19 -06:00
umarcor
4f2877d412 clean(travis): remove shellcheck from before_install (#947) 2019-09-16 20:08:40 -06:00
Gregoire Mahe
b80588d523 fix undefined cfgFile in documentation (#924) 2019-08-05 09:56:17 -06:00
Bruce Downs
993cc5372a Adjustments per PR review feedback from @bogem 2019-08-02 01:25:21 +05:00
Bruce Downs
d85196337c Correct all complaints from goimports
* i.e.
* go get golang.org/x/tools/cmd/goimports
* goimports -w *.go
* goimports -w cobra/
2019-08-02 01:25:21 +05:00
Bruce Downs
51f06c7dd1 Correct all complaints from golint
* i.e.
* go get golang.org/x/lint/golint
* go list ./... | xargs golint
2019-08-02 01:25:21 +05:00
Bruce Downs
9334a46bd6 Return an error in the case of unrunnable subcommand
* credit to @chriswhelix for initial commit
2019-08-02 01:25:21 +05:00
Bruce Downs
9552679939 Add idiomatic handling of go error in distinct main func 2019-08-02 01:25:21 +05:00
Bruce Downs
af29f95b81 Add ignore of cobra posix binary and all of intellij generated files 2019-08-02 01:25:21 +05:00
Joshua Harshman
1c9c46d5c1
Update Generator Docs to reflect changes brought in #817 (#904) 2019-07-24 10:10:51 -06:00
umarcor
2d7544ebde fix missing newline in cmd/add (#905) 2019-07-15 09:44:15 -06:00
Carol A. Scott
9a31ddff0e Add Linkerd to list of projects using Cobra (#892) 2019-07-12 09:55:10 -06:00
rsteube
21f39ca07e bash: fix shellcheck errors (#889)
https://github.com/koalaman/shellcheck/wiki/SC2207
https://github.com/koalaman/shellcheck/wiki/SC2164
2019-07-11 12:18:47 -06:00
Juan Leni
f2b07da1e2 fixing linter issues 2019-06-07 10:48:23 -04:00
Juan Leni
b635726081 considering stderr in UsageString 2019-06-07 10:48:23 -04:00
Alessio Treglia
e35034f0da Add tests 2019-06-07 10:48:23 -04:00
Juan Leni
cb27ce11fb Deprecate and maintain backwards compatibility 2019-06-07 10:48:23 -04:00
Juan Leni
618bc00f80 Allow for explicit output to err/stderr 2019-06-07 10:48:23 -04:00
Juan Leni
0ea93dd60d Fixed linter issues 2019-06-07 10:48:23 -04:00
Juan Leni
4a716d101b Extending redirection to stdout, stderr, stdin 2019-06-07 10:48:23 -04:00
Go Frendi Gunawan
5f23f55c81 Update README.md
To avoid confusion, it is better to use `localCmd` instead of `rootCmd`
2019-06-07 10:47:24 -04:00
ialidzhikov
9eb9f5c66b Add gardenctl to projects build using Cobra
Signed-off-by: ialidzhikov <i.alidjikov@gmail.com>
2019-06-07 10:33:55 -04:00
Joshua Harshman
2411ac592a remove unused struct fields 2019-06-07 10:31:03 -04:00
jharshman
984374f5b6 clean up testproject files after test executes 2019-06-07 10:31:03 -04:00
jharshman
11aa612384 test add 2019-06-07 10:31:03 -04:00
jharshman
303a3e5160 vgo - strip out unused methods 2019-06-07 10:31:03 -04:00
jharshman
0bb1506d25 remove commented field in struct 2019-06-07 10:31:03 -04:00
jharshman
2fea75b02e vgo - add command working 2019-06-07 10:31:03 -04:00