Update mitchellh/cli to fix GH-7983

This commit is contained in:
Mitchell Hashimoto 2016-08-15 12:00:05 -07:00
parent 872e457d20
commit 7131f99256
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
4 changed files with 43 additions and 21 deletions

View File

@ -1,14 +0,0 @@
sudo: false
language: go
go:
- 1.2
- 1.3
- 1.4
- 1.5
- tip
matrix:
allow_failures:
- go: tip

20
vendor/github.com/mitchellh/cli/Makefile generated vendored Normal file
View File

@ -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

View File

@ -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, " ")
}
}
}

4
vendor/vendor.json vendored
View File

@ -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",