Updates mattn/go-isatty and mitchellh/cli.
This commit is contained in:
parent
6a208e0797
commit
33ea18fb21
2
vendor/github.com/mattn/go-isatty/isatty_bsd.go
generated
vendored
2
vendor/github.com/mattn/go-isatty/isatty_bsd.go
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
// +build darwin freebsd openbsd netbsd
|
||||
// +build darwin freebsd openbsd netbsd dragonfly
|
||||
// +build !appengine
|
||||
|
||||
package isatty
|
||||
|
|
14
vendor/github.com/mitchellh/cli/.travis.yml
generated
vendored
14
vendor/github.com/mitchellh/cli/.travis.yml
generated
vendored
|
@ -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
20
vendor/github.com/mitchellh/cli/Makefile
generated
vendored
Normal 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
|
117
vendor/github.com/mitchellh/cli/cli.go
generated
vendored
117
vendor/github.com/mitchellh/cli/cli.go
generated
vendored
|
@ -122,20 +122,11 @@ func (c *CLI) Run() (int, error) {
|
|||
return 1, nil
|
||||
}
|
||||
|
||||
// If there is an invalid flag, then error
|
||||
if len(c.topFlags) > 0 {
|
||||
c.HelpWriter.Write([]byte(
|
||||
"Invalid flags before the subcommand. If these flags are for\n" +
|
||||
"the subcommand, please put them after the subcommand.\n\n"))
|
||||
c.HelpWriter.Write([]byte(c.HelpFunc(c.Commands) + "\n"))
|
||||
return 1, nil
|
||||
}
|
||||
|
||||
// Attempt to get the factory function for creating the command
|
||||
// implementation. If the command is invalid or blank, it is an error.
|
||||
raw, ok := c.commandTree.Get(c.Subcommand())
|
||||
if !ok {
|
||||
c.HelpWriter.Write([]byte(c.HelpFunc(c.Commands) + "\n"))
|
||||
c.HelpWriter.Write([]byte(c.HelpFunc(c.helpCommands(c.subcommandParent())) + "\n"))
|
||||
return 1, nil
|
||||
}
|
||||
|
||||
|
@ -150,6 +141,15 @@ func (c *CLI) Run() (int, error) {
|
|||
return 1, nil
|
||||
}
|
||||
|
||||
// If there is an invalid flag, then error
|
||||
if len(c.topFlags) > 0 {
|
||||
c.HelpWriter.Write([]byte(
|
||||
"Invalid flags before the subcommand. If these flags are for\n" +
|
||||
"the subcommand, please put them after the subcommand.\n\n"))
|
||||
c.commandHelp(command)
|
||||
return 1, nil
|
||||
}
|
||||
|
||||
code := command.Run(c.SubcommandArgs())
|
||||
if code == RunResultHelp {
|
||||
// Requesting help
|
||||
|
@ -175,6 +175,27 @@ func (c *CLI) SubcommandArgs() []string {
|
|||
return c.subcommandArgs
|
||||
}
|
||||
|
||||
// subcommandParent returns the parent of this subcommand, if there is one.
|
||||
// If there isn't on, "" is returned.
|
||||
func (c *CLI) subcommandParent() string {
|
||||
// Get the subcommand, if it is "" alread just return
|
||||
sub := c.Subcommand()
|
||||
if sub == "" {
|
||||
return sub
|
||||
}
|
||||
|
||||
// Clear any trailing spaces and find the last space
|
||||
sub = strings.TrimRight(sub, " ")
|
||||
idx := strings.LastIndex(sub, " ")
|
||||
|
||||
if idx == -1 {
|
||||
// No space means our parent is root
|
||||
return ""
|
||||
}
|
||||
|
||||
return sub[:idx]
|
||||
}
|
||||
|
||||
func (c *CLI) init() {
|
||||
if c.HelpFunc == nil {
|
||||
c.HelpFunc = BasicHelpFunc("app")
|
||||
|
@ -268,15 +289,14 @@ func (c *CLI) commandHelp(command Command) {
|
|||
}
|
||||
|
||||
// Build subcommand list if we have it
|
||||
var subcommands []map[string]interface{}
|
||||
var subcommandsTpl []map[string]interface{}
|
||||
if c.commandNested {
|
||||
// Get the matching keys
|
||||
var keys []string
|
||||
prefix := c.Subcommand() + " "
|
||||
c.commandTree.WalkPrefix(prefix, func(k string, raw interface{}) bool {
|
||||
subcommands := c.helpCommands(c.Subcommand())
|
||||
keys := make([]string, 0, len(subcommands))
|
||||
for k := range subcommands {
|
||||
keys = append(keys, k)
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
// Sort the keys
|
||||
sort.Strings(keys)
|
||||
|
@ -290,34 +310,35 @@ func (c *CLI) commandHelp(command Command) {
|
|||
}
|
||||
|
||||
// Go through and create their structures
|
||||
subcommands = make([]map[string]interface{}, len(keys))
|
||||
for i, k := range keys {
|
||||
raw, ok := c.commandTree.Get(k)
|
||||
if !ok {
|
||||
// We just checked that it should be here above. If it is
|
||||
// isn't, there are serious problems.
|
||||
panic("value is missing")
|
||||
}
|
||||
|
||||
subcommandsTpl = make([]map[string]interface{}, 0, len(subcommands))
|
||||
for _, k := range keys {
|
||||
// Get the command
|
||||
sub, err := raw.(CommandFactory)()
|
||||
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(
|
||||
"Error instantiating %q: %s", k, err)))
|
||||
}
|
||||
|
||||
// Determine some info
|
||||
name := strings.TrimPrefix(k, prefix)
|
||||
// Find the last space and make sure we only include that last part
|
||||
name := k
|
||||
if idx := strings.LastIndex(k, " "); idx > -1 {
|
||||
name = name[idx+1:]
|
||||
}
|
||||
|
||||
subcommands[i] = map[string]interface{}{
|
||||
subcommandsTpl = append(subcommandsTpl, map[string]interface{}{
|
||||
"Name": name,
|
||||
"NameAligned": name + strings.Repeat(" ", longest-len(k)),
|
||||
"Help": sub.Help(),
|
||||
"Synopsis": sub.Synopsis(),
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
data["Subcommands"] = subcommands
|
||||
data["Subcommands"] = subcommandsTpl
|
||||
|
||||
// Write
|
||||
err = t.Execute(c.HelpWriter, data)
|
||||
|
@ -330,6 +351,40 @@ func (c *CLI) commandHelp(command Command) {
|
|||
"Internal error rendering help: %s", err)))
|
||||
}
|
||||
|
||||
// helpCommands returns the subcommands for the HelpFunc argument.
|
||||
// This will only contain immediate subcommands.
|
||||
func (c *CLI) helpCommands(prefix string) map[string]CommandFactory {
|
||||
// If our prefix isn't empty, make sure it ends in ' '
|
||||
if prefix != "" && prefix[len(prefix)-1] != ' ' {
|
||||
prefix += " "
|
||||
}
|
||||
|
||||
// Get all the subkeys of this command
|
||||
var keys []string
|
||||
c.commandTree.WalkPrefix(prefix, func(k string, raw interface{}) bool {
|
||||
// Ignore any sub-sub keys, i.e. "foo bar baz" when we want "foo bar"
|
||||
if !strings.Contains(k[len(prefix):], " ") {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
|
||||
// For each of the keys return that in the map
|
||||
result := make(map[string]CommandFactory, len(keys))
|
||||
for _, k := range keys {
|
||||
raw, ok := c.commandTree.Get(k)
|
||||
if !ok {
|
||||
// We just got it via WalkPrefix above, so we just panic
|
||||
panic("not found: " + k)
|
||||
}
|
||||
|
||||
result[k] = raw.(CommandFactory)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func (c *CLI) processArgs() {
|
||||
for i, arg := range c.Args {
|
||||
if c.subcommand == "" {
|
||||
|
|
8
vendor/vendor.json
vendored
8
vendor/vendor.json
vendored
|
@ -420,8 +420,10 @@
|
|||
"revision": "f693c7e88ba316d1a0ae3e205e22a01aa3ec2848"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "xZuhljnmBysJPta/lMyYmJdujCg=",
|
||||
"path": "github.com/mattn/go-isatty",
|
||||
"revision": "56b76bdf51f7708750eac80fa38b952bb9f32639"
|
||||
"revision": "66b8e73f3f5cda9f96b69efd03dd3d7fc4a5cdb8",
|
||||
"revisionTime": "2016-08-06T12:27:52Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "OUZ1FFXyKs+Cfg9M9rmXqqweQck=",
|
||||
|
@ -430,8 +432,10 @@
|
|||
"revisionTime": "2016-07-26T03:20:27Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "yF39M9MGatDbq2d2oqlLy44jsRc=",
|
||||
"path": "github.com/mitchellh/cli",
|
||||
"revision": "cb6853d606ea4a12a15ac83cc43503df99fd28fb"
|
||||
"revision": "168daae10d6ff81b8b1201b0a4c9607d7e9b82e3",
|
||||
"revisionTime": "2016-03-23T17:07:00Z"
|
||||
},
|
||||
{
|
||||
"path": "github.com/mitchellh/copystructure",
|
||||
|
|
Loading…
Reference in a new issue