Merge pull request #8199 from hashicorp/b-update-cli
Update mitchellh/cli to fix GH-7983
This commit is contained in:
commit
db2a8b6b5d
|
@ -1,14 +0,0 @@
|
||||||
sudo: false
|
|
||||||
|
|
||||||
language: go
|
|
||||||
|
|
||||||
go:
|
|
||||||
- 1.2
|
|
||||||
- 1.3
|
|
||||||
- 1.4
|
|
||||||
- 1.5
|
|
||||||
- tip
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
allow_failures:
|
|
||||||
- go: tip
|
|
|
@ -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
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -294,7 +295,7 @@ func (c *CLI) commandHelp(command Command) {
|
||||||
// Get the matching keys
|
// Get the matching keys
|
||||||
subcommands := c.helpCommands(c.Subcommand())
|
subcommands := c.helpCommands(c.Subcommand())
|
||||||
keys := make([]string, 0, len(subcommands))
|
keys := make([]string, 0, len(subcommands))
|
||||||
for k, _ := range subcommands {
|
for k := range subcommands {
|
||||||
keys = append(keys, k)
|
keys = append(keys, k)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,8 +312,13 @@ func (c *CLI) commandHelp(command Command) {
|
||||||
|
|
||||||
// Go through and create their structures
|
// Go through and create their structures
|
||||||
subcommandsTpl = make([]map[string]interface{}, 0, len(subcommands))
|
subcommandsTpl = make([]map[string]interface{}, 0, len(subcommands))
|
||||||
for k, raw := range subcommands {
|
for _, k := range keys {
|
||||||
// Get the command
|
// Get the command
|
||||||
|
raw, ok := subcommands[k]
|
||||||
|
if !ok {
|
||||||
|
c.HelpWriter.Write([]byte(fmt.Sprintf(
|
||||||
|
"Error getting subcommand %q", k)))
|
||||||
|
}
|
||||||
sub, err := raw()
|
sub, err := raw()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.HelpWriter.Write([]byte(fmt.Sprintf(
|
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
|
// 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] != '-' {
|
if c.subcommand == "" && arg != "" && arg[0] != '-' {
|
||||||
c.subcommand = arg
|
c.subcommand = arg
|
||||||
if c.commandNested {
|
if c.commandNested {
|
||||||
// Nested CLI, the subcommand is actually the entire
|
// Nested CLI, the subcommand is actually the entire
|
||||||
// arg list up to a flag that is still a valid subcommand.
|
// 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 {
|
if ok {
|
||||||
c.subcommand = k
|
// k could be a prefix that doesn't contain the full
|
||||||
i += strings.Count(k, " ")
|
// 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, " ")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1227,8 +1227,10 @@
|
||||||
"revision": "85659debe44fab5792fc92cf755c04b115b9dc19"
|
"revision": "85659debe44fab5792fc92cf755c04b115b9dc19"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"checksumSHA1": "7niW29CvYceZ6zbia6b/LT+yD/M=",
|
||||||
"path": "github.com/mitchellh/cli",
|
"path": "github.com/mitchellh/cli",
|
||||||
"revision": "83f97d41cf100ee5f33944a8815c167d5e4aa272"
|
"revision": "fcf521421aa29bde1d93b6920dfce826d7932208",
|
||||||
|
"revisionTime": "2016-08-15T18:46:15Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "github.com/mitchellh/colorstring",
|
"path": "github.com/mitchellh/colorstring",
|
||||||
|
|
Loading…
Reference in New Issue