From 10db418b0a424efccae81714aa1d8dd2267b766f Mon Sep 17 00:00:00 2001 From: Arief Rahmansyah Date: Thu, 18 Oct 2018 23:31:18 +0800 Subject: [PATCH 01/17] update Example in README.md (#769) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e73ffee6..4316cb0fc 100644 --- a/README.md +++ b/README.md @@ -459,7 +459,7 @@ Echo works a lot like print, except it has a child command.`, } var cmdTimes = &cobra.Command{ - Use: "times [# times] [string to echo]", + Use: "times [string to echo]", Short: "Echo anything to the screen more times", Long: `echo things multiple times back to the user by providing a count and a string.`, From 0a6c06ed0bdf40caf943193d6bed506f28dfe4a3 Mon Sep 17 00:00:00 2001 From: jay vyas Date: Sat, 27 Oct 2018 09:20:53 -0400 Subject: [PATCH 02/17] specify the color as the required arg (#777) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4316cb0fc..7cb5cee50 100644 --- a/README.md +++ b/README.md @@ -399,7 +399,7 @@ var cmd = &cobra.Command{ Short: "hello", Args: func(cmd *cobra.Command, args []string) error { if len(args) < 1 { - return errors.New("requires at least one arg") + return errors.New("requires a color argument") } if myapp.IsValidColor(args[0]) { return nil From 7bab206a70d15051467d89a48268b06f3bde65ca Mon Sep 17 00:00:00 2001 From: Indradhanush Gupta Date: Tue, 30 Oct 2018 13:54:56 -0700 Subject: [PATCH 03/17] command: fix typo in docstring of InheritedFlags (#779) --- command.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command.go b/command.go index 34d1bf367..768f05d34 100644 --- a/command.go +++ b/command.go @@ -1335,7 +1335,7 @@ func (c *Command) LocalFlags() *flag.FlagSet { return c.lflags } -// InheritedFlags returns all flags which were inherited from parents commands. +// InheritedFlags returns all flags which were inherited from parent commands. func (c *Command) InheritedFlags() *flag.FlagSet { c.mergePersistentFlags() From 5e9ccc4d642b8c2b2f3c270828f04f9d38f1db33 Mon Sep 17 00:00:00 2001 From: Sergey Date: Fri, 11 Jan 2019 00:03:21 +0500 Subject: [PATCH 04/17] remove redundant 'else' (#806) --- command.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/command.go b/command.go index 768f05d34..b257f91b6 100644 --- a/command.go +++ b/command.go @@ -817,13 +817,11 @@ func (c *Command) ExecuteC() (cmd *Command, err error) { // overriding c.InitDefaultHelpCmd() - var args []string + args := c.args // Workaround FAIL with "go test -v" or "cobra.test -test.v", see #155 if c.args == nil && filepath.Base(os.Args[0]) != "cobra.test" { args = os.Args[1:] - } else { - args = c.args } var flags []string From d1e8e8b3c0ff1c8677c3899a41e153584f670f64 Mon Sep 17 00:00:00 2001 From: linzhaoming Date: Sun, 17 Feb 2019 14:57:17 +0800 Subject: [PATCH 05/17] update README.md (#826) Fix the comment: consistent with others --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7cb5cee50..e406b8a88 100644 --- a/README.md +++ b/README.md @@ -389,7 +389,7 @@ The following validators are built in: - `MinimumNArgs(int)` - the command will report an error if there are not at least N positional args. - `MaximumNArgs(int)` - the command will report an error if there are more than N positional args. - `ExactArgs(int)` - the command will report an error if there are not exactly N positional args. -- `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` +- `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` - `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. An example of setting the custom validator: From bbec970304026225a1f5fab1583b2c09d2bd9f0f Mon Sep 17 00:00:00 2001 From: Peter Edge Date: Fri, 8 Mar 2019 12:35:27 -0500 Subject: [PATCH 06/17] fix(ci): use go vet, update to Go 1.12, update shellcheck to v0.4.6 (#832) --- .circleci/config.yml | 6 +++--- .travis.yml | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6d248bcda..819446439 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,13 +15,13 @@ references: 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 @@ -31,7 +31,7 @@ jobs: 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 diff --git a/.travis.yml b/.travis.yml index 5f157433a..a8d5ce4df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,21 +2,21 @@ language: go matrix: include: - - go: 1.10.x - go: 1.11.x + - go: 1.12.x - go: tip - - go: 1.11.x + - go: 1.12.x script: diff -u <(echo -n) <(gofmt -d -s .) allow_failures: - go: tip 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.4.6/shellcheck - chmod +x bin/shellcheck script: - 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 From ee67eb44226121e4f0c99c08f7c518c0c13cb5f2 Mon Sep 17 00:00:00 2001 From: Peter Edge Date: Fri, 8 Mar 2019 12:40:41 -0500 Subject: [PATCH 07/17] add go.mod and go.sum (#833) --- go.mod | 14 ++++++++++++++ go.sum | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 go.mod create mode 100644 go.sum diff --git a/go.mod b/go.mod new file mode 100644 index 000000000..c43742c3c --- /dev/null +++ b/go.mod @@ -0,0 +1,14 @@ +module github.com/spf13/cobra + +go 1.12 + +require ( + github.com/BurntSushi/toml v0.3.1 // indirect + github.com/cpuguy83/go-md2man v1.0.8 + github.com/inconshreveable/mousetrap v1.0.0 + github.com/mitchellh/go-homedir v1.1.0 + github.com/russross/blackfriday v1.5.2 // indirect + github.com/spf13/pflag v1.0.3 + github.com/spf13/viper v1.3.1 + gopkg.in/yaml.v2 v2.2.2 +) diff --git a/go.sum b/go.sum new file mode 100644 index 000000000..f2c817e53 --- /dev/null +++ b/go.sum @@ -0,0 +1,51 @@ +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/cpuguy83/go-md2man v1.0.8 h1:DwoNytLphI8hzS2Af4D0dfaEaiSq2bN05mEm4R6vf8M= +github.com/cpuguy83/go-md2man v1.0.8/go.mod h1:N6JayAiVKtlHSnuTCeuLSQVs75hb8q+dYQLjr7cDsKY= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= +github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= +github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= +github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= +github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/viper v1.3.1 h1:5+8j8FTpnFV4nEImW/ofkzEt8VoOiLXxdYIDsB73T38= +github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a h1:1n5lsVfiQW3yfsRGu98756EH1YthsFqr/5mxHduZW2A= +golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 1820a06c598c93a882c0658bc9515f7d9cd49cb7 Mon Sep 17 00:00:00 2001 From: umarcor Date: Mon, 18 Mar 2019 17:23:22 +0100 Subject: [PATCH 08/17] chore(travis): move 'diff' job to separate stage in Travis (#839) --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a8d5ce4df..80f055428 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,16 @@ language: go +stages: + - diff + - test + matrix: include: - go: 1.11.x - go: 1.12.x - go: tip - - go: 1.12.x + - stage: diff + go: 1.12.x script: diff -u <(echo -n) <(gofmt -d -s .) allow_failures: - go: tip From 9a856c2701cd9051514b7e12da9ea1ecb30fee09 Mon Sep 17 00:00:00 2001 From: umarcor Date: Mon, 18 Mar 2019 17:25:53 +0100 Subject: [PATCH 09/17] chore(travis): use language configuration list instead of explicit entries in matrix.include (#839) --- .travis.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 80f055428..fbd967008 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,16 +4,19 @@ stages: - diff - test +go: + - 1.10.x + - 1.11.x + - 1.12.x + - tip + matrix: - include: - - go: 1.11.x - - go: 1.12.x + allow_failures: - go: tip + include: - stage: diff go: 1.12.x script: diff -u <(echo -n) <(gofmt -d -s .) - allow_failures: - - go: tip before_install: - mkdir -p bin From 6da1f4abcbcb1aeb63cb6d52db7cd1c747502288 Mon Sep 17 00:00:00 2001 From: umarcor Date: Mon, 18 Mar 2019 17:39:45 +0100 Subject: [PATCH 10/17] chore(travis): update shellcheck-docker to v0.6.0 (#839) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fbd967008..59bc10efc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ matrix: before_install: - mkdir -p bin - - curl -Lso bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.4.6/shellcheck + - curl -Lso bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.6.0/shellcheck - chmod +x bin/shellcheck script: - PATH=$PATH:$PWD/bin go test -v ./... From 1bc7f67deed64614e6a5b876bfb43c23eb419a30 Mon Sep 17 00:00:00 2001 From: praveensastry Date: Mon, 12 Nov 2018 10:01:11 +1100 Subject: [PATCH 11/17] add istio to the list of projects built with Cobra (#786) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e406b8a88..005155615 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Many of the most widely used Go projects are built using Cobra including: * [rclone](http://rclone.org/) * [nehm](https://github.com/bogem/nehm) * [Pouch](https://github.com/alibaba/pouch) +* [Istio](https://istio.io) [![Build Status](https://travis-ci.org/spf13/cobra.svg "Travis CI status")](https://travis-ci.org/spf13/cobra) [![CircleCI status](https://circleci.com/gh/spf13/cobra.png?circle-token=:circle-token "CircleCI status")](https://circleci.com/gh/spf13/cobra) From ccef21e0363f87569e89ba1091d9ad12e8dc6ff6 Mon Sep 17 00:00:00 2001 From: Peter Edge Date: Fri, 8 Mar 2019 12:30:34 -0500 Subject: [PATCH 12/17] add uber/prototool as a project built with Cobra (#831) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 005155615..742629536 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Many of the most widely used Go projects are built using Cobra including: * [nehm](https://github.com/bogem/nehm) * [Pouch](https://github.com/alibaba/pouch) * [Istio](https://istio.io) +* [Prototool](https://github.com/uber/prototool) [![Build Status](https://travis-ci.org/spf13/cobra.svg "Travis CI status")](https://travis-ci.org/spf13/cobra) [![CircleCI status](https://circleci.com/gh/spf13/cobra.png?circle-token=:circle-token "CircleCI status")](https://circleci.com/gh/spf13/cobra) From 09c3b19b9563ec9bf1de7e96f5d327e791d40844 Mon Sep 17 00:00:00 2001 From: joshuabezaleel Date: Wed, 13 Feb 2019 22:33:44 +0700 Subject: [PATCH 13/17] add mattermost-server as a project built with Cobra (#824) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 742629536..adb69ce43 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Many of the most widely used Go projects are built using Cobra including: * [Pouch](https://github.com/alibaba/pouch) * [Istio](https://istio.io) * [Prototool](https://github.com/uber/prototool) +* [mattermost-server](https://github.com/mattermost/mattermost-server) [![Build Status](https://travis-ci.org/spf13/cobra.svg "Travis CI status")](https://travis-ci.org/spf13/cobra) [![CircleCI status](https://circleci.com/gh/spf13/cobra.png?circle-token=:circle-token "CircleCI status")](https://circleci.com/gh/spf13/cobra) From 685e640f2eea43ae3bb862f201f6db1735ae28f5 Mon Sep 17 00:00:00 2001 From: umarcor Date: Mon, 18 Mar 2019 20:12:38 +0100 Subject: [PATCH 14/17] update(README.md): separate projects by commas, instead of using a list --- README.md | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index adb69ce43..ff16e3f60 100644 --- a/README.md +++ b/README.md @@ -2,28 +2,28 @@ Cobra is both a library for creating powerful modern CLI applications as well as a program to generate applications and command files. -Many of the most widely used Go projects are built using Cobra including: - -* [Kubernetes](http://kubernetes.io/) -* [Hugo](http://gohugo.io) -* [rkt](https://github.com/coreos/rkt) -* [etcd](https://github.com/coreos/etcd) -* [Moby (former Docker)](https://github.com/moby/moby) -* [Docker (distribution)](https://github.com/docker/distribution) -* [OpenShift](https://www.openshift.com/) -* [Delve](https://github.com/derekparker/delve) -* [GopherJS](http://www.gopherjs.org/) -* [CockroachDB](http://www.cockroachlabs.com/) -* [Bleve](http://www.blevesearch.com/) -* [ProjectAtomic (enterprise)](http://www.projectatomic.io/) -* [Giant Swarm's gsctl](https://github.com/giantswarm/gsctl) -* [Nanobox](https://github.com/nanobox-io/nanobox)/[Nanopack](https://github.com/nanopack) -* [rclone](http://rclone.org/) -* [nehm](https://github.com/bogem/nehm) -* [Pouch](https://github.com/alibaba/pouch) -* [Istio](https://istio.io) -* [Prototool](https://github.com/uber/prototool) -* [mattermost-server](https://github.com/mattermost/mattermost-server) +Many of the most widely used Go projects are built using Cobra, such as: +[Kubernetes](http://kubernetes.io/), +[Hugo](http://gohugo.io), +[rkt](https://github.com/coreos/rkt), +[etcd](https://github.com/coreos/etcd), +[Moby (former Docker)](https://github.com/moby/moby), +[Docker (distribution)](https://github.com/docker/distribution), +[OpenShift](https://www.openshift.com/), +[Delve](https://github.com/derekparker/delve), +[GopherJS](http://www.gopherjs.org/), +[CockroachDB](http://www.cockroachlabs.com/), +[Bleve](http://www.blevesearch.com/), +[ProjectAtomic (enterprise)](http://www.projectatomic.io/), +[Giant Swarm's gsctl](https://github.com/giantswarm/gsctl), +[Nanobox](https://github.com/nanobox-io/nanobox)/[Nanopack](https://github.com/nanopack), +[rclone](http://rclone.org/), +[nehm](https://github.com/bogem/nehm), +[Pouch](https://github.com/alibaba/pouch), +[Istio](https://istio.io), +[Prototool](https://github.com/uber/prototool), +[mattermost-server](https://github.com/mattermost/mattermost-server), +etc. [![Build Status](https://travis-ci.org/spf13/cobra.svg "Travis CI status")](https://travis-ci.org/spf13/cobra) [![CircleCI status](https://circleci.com/gh/spf13/cobra.png?circle-token=:circle-token "CircleCI status")](https://circleci.com/gh/spf13/cobra) From 7a5404953c187754998818a17b72f87697e7696e Mon Sep 17 00:00:00 2001 From: umarcor Date: Mon, 18 Mar 2019 20:39:21 +0100 Subject: [PATCH 15/17] chore: update viper to v1.3.2 and go-md2man to v1.0.10 --- go.mod | 5 ++--- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index c43742c3c..9a9eb65a3 100644 --- a/go.mod +++ b/go.mod @@ -4,11 +4,10 @@ go 1.12 require ( github.com/BurntSushi/toml v0.3.1 // indirect - github.com/cpuguy83/go-md2man v1.0.8 + github.com/cpuguy83/go-md2man v1.0.10 github.com/inconshreveable/mousetrap v1.0.0 github.com/mitchellh/go-homedir v1.1.0 - github.com/russross/blackfriday v1.5.2 // indirect github.com/spf13/pflag v1.0.3 - github.com/spf13/viper v1.3.1 + github.com/spf13/viper v1.3.2 gopkg.in/yaml.v2 v2.2.2 ) diff --git a/go.sum b/go.sum index f2c817e53..9761f4d03 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5 github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/cpuguy83/go-md2man v1.0.8 h1:DwoNytLphI8hzS2Af4D0dfaEaiSq2bN05mEm4R6vf8M= -github.com/cpuguy83/go-md2man v1.0.8/go.mod h1:N6JayAiVKtlHSnuTCeuLSQVs75hb8q+dYQLjr7cDsKY= +github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= +github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= @@ -34,8 +34,8 @@ github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9 github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/viper v1.3.1 h1:5+8j8FTpnFV4nEImW/ofkzEt8VoOiLXxdYIDsB73T38= -github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M= +github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= From c0ff9f1c25a1eb2232b979d2c45723cecba2afc1 Mon Sep 17 00:00:00 2001 From: umarcor Date: Mon, 18 Mar 2019 21:12:13 +0100 Subject: [PATCH 16/17] fix: convert CRLF to LF when comparing files --- cobra/cmd/golden_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cobra/cmd/golden_test.go b/cobra/cmd/golden_test.go index 59a5a1c9f..9010caa13 100644 --- a/cobra/cmd/golden_test.go +++ b/cobra/cmd/golden_test.go @@ -17,6 +17,11 @@ func init() { initCmd.SetOutput(new(bytes.Buffer)) } +// ensureLF converts any \r\n to \n +func ensureLF(content []byte) []byte { + return bytes.Replace(content, []byte("\r\n"), []byte("\n"), -1) +} + // compareFiles compares the content of files with pathA and pathB. // If contents are equal, it returns nil. // If not, it returns which files are not equal @@ -30,7 +35,7 @@ func compareFiles(pathA, pathB string) error { if err != nil { return err } - if !bytes.Equal(contentA, contentB) { + if !bytes.Equal(ensureLF(contentA), ensureLF(contentB)) { output := new(bytes.Buffer) output.WriteString(fmt.Sprintf("%q and %q are not equal!\n\n", pathA, pathB)) From 37c2ef05ae0e4062d620c636777b4815e2adc69f Mon Sep 17 00:00:00 2001 From: umarcor Date: Tue, 19 Mar 2019 19:49:03 +0100 Subject: [PATCH 17/17] use kyoh86/richgo to provide colored test outputs --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 59bc10efc..38b85f499 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,8 +22,9 @@ before_install: - mkdir -p bin - 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/richgo script: - - 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 vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint');