[TrivialPatches] Typos in README.md, fix and update CI, update projects list... (#840)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* 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
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
7 files+118 added−39 removed
- other:+118 added−39 removed
Provenance
- Commit
5755ecf- Tree
91f7b73- Author
umarcor <38422348+umarcor@users.noreply.github.com>- Committer
Eric Paris <eparis@redhat.com>- Parent
ba1052d
7 files changed+118 added−39 removed
modified:.circleci/config.yml+3 added-3 removed
13 unmodified lines1415161718181920212223242425262728293031323334343536373815 unmodified lines13 unmodified lines go get -t -v ./... PATH=$PATH:$PWD/bin go test -v ./... go build if [ -z $NOVET ]; then diff -u <(echo -n) <(go tool vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint'); diff -u <(echo -n) <(go vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint'); fi
jobs: go-current: docker: - image: circleci/golang:1.11 - image: circleci/golang:1.12 working_directory: *workspace steps: - checkout - *run_tests - run: name: "Check formatting" command: diff -u <(echo -n) <(gofmt -d -s .) go-previous: docker: - image: circleci/golang:1.10 - image: circleci/golang:1.11 working_directory: *workspace steps: - checkout - *run_tests15 unmodified linesmodified:cobra/cmd/golden_test.go+6 added-1 removed
15 unmodified lines16 addCmd.SetOutput(new(bytes.Buffer))17 initCmd.SetOutput(new(bytes.Buffer))18 }19 20+// ensureLF converts any \r\n to \n21+func ensureLF(content []byte) []byte {22+ return bytes.Replace(content, []byte("\r\n"), []byte("\n"), -1)23+}24+25 // compareFiles compares the content of files with pathA and pathB.26 // If contents are equal, it returns nil.27 // If not, it returns which files are not equal28 // and diff (if system has diff command) between these files.5 unmodified lines34 contentB, err := ioutil.ReadFile(pathB)35 if err != nil {36 return err37 }33- if !bytes.Equal(contentA, contentB) {38+ if !bytes.Equal(ensureLF(contentA), ensureLF(contentB)) {39 output := new(bytes.Buffer)40 output.WriteString(fmt.Sprintf("%q and %q are not equal!\n\n", pathA, pathB))41 42 diffPath, err := exec.LookPath("diff")40 unmodified linesmodified:.travis.yml+18 added-9 removed
12345678910111213456789141516171819202122152324252618272829213031language: go
stages: - diff - test
go: - 1.10.x - 1.11.x - 1.12.x - tip
matrix: include: - go: 1.10.x - go: 1.11.x - go: tip - go: 1.11.x script: diff -u <(echo -n) <(gofmt -d -s .) allow_failures: - go: tip include: - stage: diff go: 1.12.x script: diff -u <(echo -n) <(gofmt -d -s .)
before_install: - mkdir -p bin - curl -Lso bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.4.3/shellcheck - curl -Lso bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.6.0/shellcheck - chmod +x bin/shellcheck - go get -u github.com/kyoh86/richgoscript: - PATH=$PATH:$PWD/bin go test -v ./... - PATH=$PATH:$PWD/bin richgo test -v ./... - go build - if [ -z $NOVET ]; then diff -u <(echo -n) <(go tool vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint'); diff -u <(echo -n) <(go vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint'); fimodified:command.go+2 added-4 removed
815 unmodified lines816 // initialize help as the last point possible to allow for user817 // overriding818 c.InitDefaultHelpCmd()819 820- var args []string820+ args := c.args821 822 // Workaround FAIL with "go test -v" or "cobra.test -test.v", see #155823 if c.args == nil && filepath.Base(os.Args[0]) != "cobra.test" {824 args = os.Args[1:]825- } else {826- args = c.args825 }826 827 var flags []string828 if c.TraverseChildren {503 unmodified lines1332 c.PersistentFlags().VisitAll(addToLocal)1333 return c.lflags1334 }1335 1338-// InheritedFlags returns all flags which were inherited from parents commands.1336+// InheritedFlags returns all flags which were inherited from parent commands.1337 func (c *Command) InheritedFlags() *flag.FlagSet {1338 c.mergePersistentFlags()1339 1340 if c.iflags == nil {175 unmodified linesadded:go.mod+13 added
1+module github.com/spf13/cobra2+3+go 1.124+5+require (6+ github.com/BurntSushi/toml v0.3.1 // indirect7+ github.com/cpuguy83/go-md2man v1.0.108+ github.com/inconshreveable/mousetrap v1.0.09+ github.com/mitchellh/go-homedir v1.1.010+ github.com/spf13/pflag v1.0.311+ github.com/spf13/viper v1.3.212+ gopkg.in/yaml.v2 v2.2.213+)added:go.sum+51 added
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=modified:README.md+25 added-22 removed
1 2 3 Cobra is both a library for creating powerful modern CLI applications as well as a program to generate applications and command files.4 5-Many of the most widely used Go projects are built using Cobra including: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.27 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)24-28 [](https://travis-ci.org/spf13/cobra)29 [](https://circleci.com/gh/spf13/cobra)30 [](https://godoc.org/github.com/spf13/cobra)31 359 unmodified lines391 - `OnlyValidArgs` - the command will report an error if there are any positional args that are not in the `ValidArgs` field of `Command`.392 - `MinimumNArgs(int)` - the command will report an error if there are not at least N positional args.393 - `MaximumNArgs(int)` - the command will report an error if there are more than N positional args.394 - `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`396 - `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.397 398 An example of setting the custom validator:399 1 unmodified line401 var cmd = &cobra.Command{402 Short: "hello",403 Args: func(cmd *cobra.Command, args []string) error {404 if len(args) < 1 {402- return errors.New("requires at least one arg")405+ return errors.New("requires a color argument")406 }407 if myapp.IsValidColor(args[0]) {408 return nil409 }51 unmodified lines461 },462 }463 464 var cmdTimes = &cobra.Command{462- Use: "times [# times] [string to echo]",465+ Use: "times [string to echo]",466 Short: "Echo anything to the screen more times",467 Long: `echo things multiple times back to the user by providing468 a count and a string.`,469 Args: cobra.MinimumNArgs(1),265 unmodified lines