Skip to content

Commit 5755ecf

Browse files
umarcoreparis
authored andcommitted
[TrivialPatches] Typos in README.md, fix and update CI, update projects list... (#840)
* update Example in README.md (#769) * specify the color as the required arg (#777) * command: fix typo in docstring of InheritedFlags (#779) * add istio to the list of projects built with Cobra (#786) * remove redundant 'else' (#806) * add mattermost-server as a project built with Cobra (#824) * update README.md (#826) Fix the comment: consistent with others * add uber/prototool as a project built with Cobra (#831) * fix(ci): use go vet, update to Go 1.12, update shellcheck to v0.4.6 (#832) * add go.mod and go.sum (#833) * chore(travis): move 'diff' job to separate stage in Travis (#839) * chore(travis): use language configuration list instead of explicit entries in matrix.include (#839) * chore(travis): update shellcheck-docker to v0.6.0 (#839) * update(README.md): separate projects by commas, instead of using a list * chore: update viper to v1.3.2 and go-md2man to v1.0.10 * fix: convert CRLF to LF when comparing files * use kyoh86/richgo to provide colored test outputs
1 parent ba1052d commit 5755ecf

File tree

7 files changed

+118
-39
lines changed

7 files changed

+118
-39
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ references:
1515
PATH=$PATH:$PWD/bin go test -v ./...
1616
go build
1717
if [ -z $NOVET ]; then
18-
diff -u <(echo -n) <(go tool vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint');
18+
diff -u <(echo -n) <(go vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint');
1919
fi
2020
2121
jobs:
2222
go-current:
2323
docker:
24-
- image: circleci/golang:1.11
24+
- image: circleci/golang:1.12
2525
working_directory: *workspace
2626
steps:
2727
- checkout
@@ -31,7 +31,7 @@ jobs:
3131
command: diff -u <(echo -n) <(gofmt -d -s .)
3232
go-previous:
3333
docker:
34-
- image: circleci/golang:1.10
34+
- image: circleci/golang:1.11
3535
working_directory: *workspace
3636
steps:
3737
- checkout

.travis.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11
language: go
22

3+
stages:
4+
- diff
5+
- test
6+
7+
go:
8+
- 1.10.x
9+
- 1.11.x
10+
- 1.12.x
11+
- tip
12+
313
matrix:
4-
include:
5-
- go: 1.10.x
6-
- go: 1.11.x
7-
- go: tip
8-
- go: 1.11.x
9-
script: diff -u <(echo -n) <(gofmt -d -s .)
1014
allow_failures:
1115
- go: tip
16+
include:
17+
- stage: diff
18+
go: 1.12.x
19+
script: diff -u <(echo -n) <(gofmt -d -s .)
1220

1321
before_install:
1422
- mkdir -p bin
15-
- curl -Lso bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.4.3/shellcheck
23+
- curl -Lso bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.6.0/shellcheck
1624
- chmod +x bin/shellcheck
25+
- go get -u github.com/kyoh86/richgo
1726
script:
18-
- PATH=$PATH:$PWD/bin go test -v ./...
27+
- PATH=$PATH:$PWD/bin richgo test -v ./...
1928
- go build
2029
- if [ -z $NOVET ]; then
21-
diff -u <(echo -n) <(go tool vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint');
30+
diff -u <(echo -n) <(go vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint');
2231
fi

README.md

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,28 @@
22

33
Cobra is both a library for creating powerful modern CLI applications as well as a program to generate applications and command files.
44

5-
Many of the most widely used Go projects are built using Cobra including:
6-
7-
* [Kubernetes](http://kubernetes.io/)
8-
* [Hugo](http://gohugo.io)
9-
* [rkt](https://github.com/coreos/rkt)
10-
* [etcd](https://github.com/coreos/etcd)
11-
* [Moby (former Docker)](https://github.com/moby/moby)
12-
* [Docker (distribution)](https://github.com/docker/distribution)
13-
* [OpenShift](https://www.openshift.com/)
14-
* [Delve](https://github.com/derekparker/delve)
15-
* [GopherJS](http://www.gopherjs.org/)
16-
* [CockroachDB](http://www.cockroachlabs.com/)
17-
* [Bleve](http://www.blevesearch.com/)
18-
* [ProjectAtomic (enterprise)](http://www.projectatomic.io/)
19-
* [Giant Swarm's gsctl](https://github.com/giantswarm/gsctl)
20-
* [Nanobox](https://github.com/nanobox-io/nanobox)/[Nanopack](https://github.com/nanopack)
21-
* [rclone](http://rclone.org/)
22-
* [nehm](https://github.com/bogem/nehm)
23-
* [Pouch](https://github.com/alibaba/pouch)
5+
Many of the most widely used Go projects are built using Cobra, such as:
6+
[Kubernetes](http://kubernetes.io/),
7+
[Hugo](http://gohugo.io),
8+
[rkt](https://github.com/coreos/rkt),
9+
[etcd](https://github.com/coreos/etcd),
10+
[Moby (former Docker)](https://github.com/moby/moby),
11+
[Docker (distribution)](https://github.com/docker/distribution),
12+
[OpenShift](https://www.openshift.com/),
13+
[Delve](https://github.com/derekparker/delve),
14+
[GopherJS](http://www.gopherjs.org/),
15+
[CockroachDB](http://www.cockroachlabs.com/),
16+
[Bleve](http://www.blevesearch.com/),
17+
[ProjectAtomic (enterprise)](http://www.projectatomic.io/),
18+
[Giant Swarm's gsctl](https://github.com/giantswarm/gsctl),
19+
[Nanobox](https://github.com/nanobox-io/nanobox)/[Nanopack](https://github.com/nanopack),
20+
[rclone](http://rclone.org/),
21+
[nehm](https://github.com/bogem/nehm),
22+
[Pouch](https://github.com/alibaba/pouch),
23+
[Istio](https://istio.io),
24+
[Prototool](https://github.com/uber/prototool),
25+
[mattermost-server](https://github.com/mattermost/mattermost-server),
26+
etc.
2427

2528
[![Build Status](https://travis-ci.org/spf13/cobra.svg "Travis CI status")](https://travis-ci.org/spf13/cobra)
2629
[![CircleCI status](https://circleci.com/gh/spf13/cobra.png?circle-token=:circle-token "CircleCI status")](https://circleci.com/gh/spf13/cobra)
@@ -389,7 +392,7 @@ The following validators are built in:
389392
- `MinimumNArgs(int)` - the command will report an error if there are not at least N positional args.
390393
- `MaximumNArgs(int)` - the command will report an error if there are more than N positional args.
391394
- `ExactArgs(int)` - the command will report an error if there are not exactly N positional args.
392-
- `ExactValidArgs(int)` = the command will report and error if there are not exactly N positional args OR if there are any positional args that are not in the `ValidArgs` field of `Command`
395+
- `ExactValidArgs(int)` - the command will report an error if there are not exactly N positional args OR if there are any positional args that are not in the `ValidArgs` field of `Command`
393396
- `RangeArgs(min, max)` - the command will report an error if the number of args is not between the minimum and maximum number of expected args.
394397

395398
An example of setting the custom validator:
@@ -399,7 +402,7 @@ var cmd = &cobra.Command{
399402
Short: "hello",
400403
Args: func(cmd *cobra.Command, args []string) error {
401404
if len(args) < 1 {
402-
return errors.New("requires at least one arg")
405+
return errors.New("requires a color argument")
403406
}
404407
if myapp.IsValidColor(args[0]) {
405408
return nil
@@ -459,7 +462,7 @@ Echo works a lot like print, except it has a child command.`,
459462
}
460463

461464
var cmdTimes = &cobra.Command{
462-
Use: "times [# times] [string to echo]",
465+
Use: "times [string to echo]",
463466
Short: "Echo anything to the screen more times",
464467
Long: `echo things multiple times back to the user by providing
465468
a count and a string.`,

cobra/cmd/golden_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ func init() {
1717
initCmd.SetOutput(new(bytes.Buffer))
1818
}
1919

20+
// ensureLF converts any \r\n to \n
21+
func ensureLF(content []byte) []byte {
22+
return bytes.Replace(content, []byte("\r\n"), []byte("\n"), -1)
23+
}
24+
2025
// compareFiles compares the content of files with pathA and pathB.
2126
// If contents are equal, it returns nil.
2227
// If not, it returns which files are not equal
@@ -30,7 +35,7 @@ func compareFiles(pathA, pathB string) error {
3035
if err != nil {
3136
return err
3237
}
33-
if !bytes.Equal(contentA, contentB) {
38+
if !bytes.Equal(ensureLF(contentA), ensureLF(contentB)) {
3439
output := new(bytes.Buffer)
3540
output.WriteString(fmt.Sprintf("%q and %q are not equal!\n\n", pathA, pathB))
3641

command.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -817,13 +817,11 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
817817
// overriding
818818
c.InitDefaultHelpCmd()
819819

820-
var args []string
820+
args := c.args
821821

822822
// Workaround FAIL with "go test -v" or "cobra.test -test.v", see #155
823823
if c.args == nil && filepath.Base(os.Args[0]) != "cobra.test" {
824824
args = os.Args[1:]
825-
} else {
826-
args = c.args
827825
}
828826

829827
var flags []string
@@ -1335,7 +1333,7 @@ func (c *Command) LocalFlags() *flag.FlagSet {
13351333
return c.lflags
13361334
}
13371335

1338-
// InheritedFlags returns all flags which were inherited from parents commands.
1336+
// InheritedFlags returns all flags which were inherited from parent commands.
13391337
func (c *Command) InheritedFlags() *flag.FlagSet {
13401338
c.mergePersistentFlags()
13411339

go.mod

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module github.com/spf13/cobra
2+
3+
go 1.12
4+
5+
require (
6+
github.com/BurntSushi/toml v0.3.1 // indirect
7+
github.com/cpuguy83/go-md2man v1.0.10
8+
github.com/inconshreveable/mousetrap v1.0.0
9+
github.com/mitchellh/go-homedir v1.1.0
10+
github.com/spf13/pflag v1.0.3
11+
github.com/spf13/viper v1.3.2
12+
gopkg.in/yaml.v2 v2.2.2
13+
)

go.sum

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
2+
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
3+
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
4+
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
5+
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
6+
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
7+
github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
8+
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
9+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
10+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
11+
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
12+
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
13+
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
14+
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
15+
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
16+
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
17+
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
18+
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
19+
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
20+
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
21+
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
22+
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
23+
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
24+
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
25+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
26+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
27+
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
28+
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
29+
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
30+
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
31+
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
32+
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
33+
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
34+
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
35+
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
36+
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
37+
github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M=
38+
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
39+
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
40+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
41+
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
42+
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
43+
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
44+
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a h1:1n5lsVfiQW3yfsRGu98756EH1YthsFqr/5mxHduZW2A=
45+
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
46+
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
47+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
48+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
49+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
50+
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
51+
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

0 commit comments

Comments
 (0)