diff --git a/vendor/github.com/mitchellh/cli/.travis.yml b/vendor/github.com/mitchellh/cli/.travis.yml deleted file mode 100644 index c2f4ab263..000000000 --- a/vendor/github.com/mitchellh/cli/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -sudo: false - -language: go - -go: - - 1.2 - - 1.3 - - 1.4 - - 1.5 - - tip - -matrix: - allow_failures: - - go: tip diff --git a/vendor/github.com/mitchellh/cli/Makefile b/vendor/github.com/mitchellh/cli/Makefile new file mode 100644 index 000000000..4874b0082 --- /dev/null +++ b/vendor/github.com/mitchellh/cli/Makefile @@ -0,0 +1,20 @@ +TEST?=./... + +default: test + +# test runs the test suite and vets the code +test: + go list $(TEST) | xargs -n1 go test -timeout=60s -parallel=10 $(TESTARGS) + +# testrace runs the race checker +testrace: + go list $(TEST) | xargs -n1 go test -race $(TESTARGS) + +# updatedeps installs all the dependencies to run and build +updatedeps: + go list ./... \ + | xargs go list -f '{{ join .Deps "\n" }}{{ printf "\n" }}{{ join .TestImports "\n" }}' \ + | grep -v github.com/mitchellh/cli \ + | xargs go get -f -u -v + +.PHONY: test testrace updatedeps diff --git a/vendor/github.com/mitchellh/cli/cli.go b/vendor/github.com/mitchellh/cli/cli.go index 81b14f1fc..fbc0722f4 100644 --- a/vendor/github.com/mitchellh/cli/cli.go +++ b/vendor/github.com/mitchellh/cli/cli.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "os" + "regexp" "sort" "strings" "sync" @@ -294,7 +295,7 @@ func (c *CLI) commandHelp(command Command) { // Get the matching keys subcommands := c.helpCommands(c.Subcommand()) keys := make([]string, 0, len(subcommands)) - for k, _ := range subcommands { + for k := range subcommands { keys = append(keys, k) } @@ -311,8 +312,13 @@ func (c *CLI) commandHelp(command Command) { // Go through and create their structures subcommandsTpl = make([]map[string]interface{}, 0, len(subcommands)) - for k, raw := range subcommands { + for _, k := range keys { // Get the command + raw, ok := subcommands[k] + if !ok { + c.HelpWriter.Write([]byte(fmt.Sprintf( + "Error getting subcommand %q", k))) + } sub, err := raw() if err != nil { c.HelpWriter.Write([]byte(fmt.Sprintf( @@ -400,16 +406,24 @@ func (c *CLI) processArgs() { } // If we didn't find a subcommand yet and this is the first non-flag - // argument, then this is our subcommand. j + // argument, then this is our subcommand. if c.subcommand == "" && arg != "" && arg[0] != '-' { c.subcommand = arg if c.commandNested { // Nested CLI, the subcommand is actually the entire // arg list up to a flag that is still a valid subcommand. - k, _, ok := c.commandTree.LongestPrefix(strings.Join(c.Args[i:], " ")) + searchKey := strings.Join(c.Args[i:], " ") + k, _, ok := c.commandTree.LongestPrefix(searchKey) if ok { - c.subcommand = k - i += strings.Count(k, " ") + // k could be a prefix that doesn't contain the full + // command such as "foo" instead of "foobar", so we + // need to verify that we have an entire key. To do that, + // we look for an ending in a space or an end of string. + reVerify := regexp.MustCompile(regexp.QuoteMeta(k) + `( |$)`) + if reVerify.MatchString(searchKey) { + c.subcommand = k + i += strings.Count(k, " ") + } } } diff --git a/vendor/vendor.json b/vendor/vendor.json index 2e3e9d939..d589aaeb9 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -1227,8 +1227,10 @@ "revision": "85659debe44fab5792fc92cf755c04b115b9dc19" }, { + "checksumSHA1": "7niW29CvYceZ6zbia6b/LT+yD/M=", "path": "github.com/mitchellh/cli", - "revision": "83f97d41cf100ee5f33944a8815c167d5e4aa272" + "revision": "fcf521421aa29bde1d93b6920dfce826d7932208", + "revisionTime": "2016-08-15T18:46:15Z" }, { "path": "github.com/mitchellh/colorstring",