diff --git a/Gopkg.lock b/Gopkg.lock index 00f0082..837d41e 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -4,7 +4,7 @@ [[projects]] name = "github.com/gorilla/handlers" packages = ["."] - revision = "a4d79d4487c2430a17d9dc8a1f74d1a6ed6908ca" + revision = "a4043c62cc2329bacda331d33fc908ab11ef0ec3" source = "https://github.com/gorilla/handlers" version = "v1.2.1" @@ -18,7 +18,7 @@ branch = "master" name = "github.com/spf13/cobra" packages = ["."] - revision = "4d647c8944eb42504a714e57e97f244ed6344722" + revision = "715f41bd7a70b5111f898b71ab484da52ee6266d" [[projects]] branch = "master" diff --git a/vendor/github.com/gorilla/handlers/.travis.yml b/vendor/github.com/gorilla/handlers/.travis.yml index 1ba74af..4ea1e7a 100644 --- a/vendor/github.com/gorilla/handlers/.travis.yml +++ b/vendor/github.com/gorilla/handlers/.travis.yml @@ -7,7 +7,6 @@ matrix: - go: 1.5 - go: 1.6 - go: 1.7 - - go: 1.8 - go: tip allow_failures: - go: tip @@ -17,4 +16,3 @@ script: - diff -u <(echo -n) <(gofmt -d .) - go vet $(go list ./... | grep -v /vendor/) - go test -v -race ./... - diff --git a/vendor/github.com/spf13/cobra/cobra.go b/vendor/github.com/spf13/cobra/cobra.go index 2726d19..8928cef 100644 --- a/vendor/github.com/spf13/cobra/cobra.go +++ b/vendor/github.com/spf13/cobra/cobra.go @@ -47,6 +47,15 @@ var EnablePrefixMatching = false // To disable sorting, set it to false. var EnableCommandSorting = true +// MousetrapHelpText enables an information splash screen on Windows +// if the CLI is started from explorer.exe. +// To disable the mousetrap, just set this variable to blank string (""). +// Works only on Microsoft Windows. +var MousetrapHelpText string = `This is a command line tool. + +You need to open cmd.exe and run it from there. +` + // AddTemplateFunc adds a template function that's available to Usage and Help // template generation. func AddTemplateFunc(name string, tmplFunc interface{}) { diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/helpers.go b/vendor/github.com/spf13/cobra/cobra/cmd/helpers.go index 6114227..c5e261c 100644 --- a/vendor/github.com/spf13/cobra/cobra/cmd/helpers.go +++ b/vendor/github.com/spf13/cobra/cobra/cmd/helpers.go @@ -45,24 +45,34 @@ func er(msg interface{}) { } // isEmpty checks if a given path is empty. +// Hidden files in path are ignored. func isEmpty(path string) bool { fi, err := os.Stat(path) if err != nil { er(err) } - if fi.IsDir() { - f, err := os.Open(path) - if err != nil { - er(err) - } - defer f.Close() - dirs, err := f.Readdirnames(1) - if err != nil && err != io.EOF { - er(err) - } - return len(dirs) == 0 + + if !fi.IsDir() { + return fi.Size() == 0 } - return fi.Size() == 0 + + f, err := os.Open(path) + if err != nil { + er(err) + } + defer f.Close() + + names, err := f.Readdirnames(-1) + if err != nil && err != io.EOF { + er(err) + } + + for _, name := range names { + if len(name) > 0 && name[0] != '.' { + return false + } + } + return true } // exists checks if a file or directory exists. diff --git a/vendor/github.com/spf13/cobra/command.go b/vendor/github.com/spf13/cobra/command.go index 2cd6ee8..c3e16b1 100644 --- a/vendor/github.com/spf13/cobra/command.go +++ b/vendor/github.com/spf13/cobra/command.go @@ -767,28 +767,28 @@ func (c *Command) InitDefaultHelpFlag() { // It is called automatically by executing the c or by calling help and usage. // If c already has help command or c has no subcommands, it will do nothing. func (c *Command) InitDefaultHelpCmd() { - if c.helpCommand != nil || !c.HasSubCommands() { + if !c.HasSubCommands() { return } - c.helpCommand = &Command{ - Use: "help [command]", - Short: "Help about any command", - Long: `Help provides help for any command in the application. - Simply type ` + c.Name() + ` help [path to command] for full details.`, - PersistentPreRun: func(cmd *Command, args []string) {}, - PersistentPostRun: func(cmd *Command, args []string) {}, + if c.helpCommand == nil { + c.helpCommand = &Command{ + Use: "help [command]", + Short: "Help about any command", + Long: `Help provides help for any command in the application. +Simply type ` + c.Name() + ` help [path to command] for full details.`, - Run: func(c *Command, args []string) { - cmd, _, e := c.Root().Find(args) - if cmd == nil || e != nil { - c.Printf("Unknown help topic %#q\n", args) - c.Root().Usage() - } else { - cmd.InitDefaultHelpFlag() // make possible 'help' flag to be shown - cmd.Help() - } - }, + Run: func(c *Command, args []string) { + cmd, _, e := c.Root().Find(args) + if cmd == nil || e != nil { + c.Printf("Unknown help topic %#q\n", args) + c.Root().Usage() + } else { + cmd.InitDefaultHelpFlag() // make possible 'help' flag to be shown + cmd.Help() + } + }, + } } c.RemoveCommand(c.helpCommand) c.AddCommand(c.helpCommand) diff --git a/vendor/github.com/spf13/cobra/command_test.go b/vendor/github.com/spf13/cobra/command_test.go index f4fe146..aa6658f 100644 --- a/vendor/github.com/spf13/cobra/command_test.go +++ b/vendor/github.com/spf13/cobra/command_test.go @@ -120,7 +120,6 @@ func TestStripFlags(t *testing.T) { } func TestDisableFlagParsing(t *testing.T) { - as := []string{"-v", "-race", "-file", "foo.go"} targs := []string{} cmdPrint := &Command{ DisableFlagParsing: true, @@ -128,14 +127,14 @@ func TestDisableFlagParsing(t *testing.T) { targs = args }, } - osargs := []string{"cmd"} - os.Args = append(osargs, as...) + args := []string{"cmd", "-v", "-race", "-file", "foo.go"} + cmdPrint.SetArgs(args) err := cmdPrint.Execute() if err != nil { t.Error(err) } - if !reflect.DeepEqual(as, targs) { - t.Errorf("expected: %v, got: %v", as, targs) + if !reflect.DeepEqual(args, targs) { + t.Errorf("expected: %v, got: %v", args, targs) } } @@ -316,5 +315,35 @@ func TestUseDeprecatedFlags(t *testing.T) { if !strings.Contains(output.String(), "This flag is deprecated") { t.Errorf("Expected to contain deprecated message, but got %q", output.String()) } - +} + +// TestSetHelpCommand checks, if SetHelpCommand works correctly. +func TestSetHelpCommand(t *testing.T) { + c := &Command{Use: "c", Run: func(*Command, []string) {}} + output := new(bytes.Buffer) + c.SetOutput(output) + c.SetArgs([]string{"help"}) + + // Help will not be shown, if c has no subcommands. + c.AddCommand(&Command{ + Use: "empty", + Run: func(cmd *Command, args []string) {}, + }) + + correctMessage := "WORKS" + c.SetHelpCommand(&Command{ + Use: "help [command]", + Short: "Help about any command", + Long: `Help provides help for any command in the application. + Simply type ` + c.Name() + ` help [path to command] for full details.`, + Run: func(c *Command, args []string) { c.Print(correctMessage) }, + }) + + if err := c.Execute(); err != nil { + t.Error("Unexpected error:", err) + } + + if output.String() != correctMessage { + t.Errorf("Expected to contain %q message, but got %q", correctMessage, output.String()) + } } diff --git a/vendor/github.com/spf13/cobra/command_win.go b/vendor/github.com/spf13/cobra/command_win.go index 4b0eaa1..edec728 100644 --- a/vendor/github.com/spf13/cobra/command_win.go +++ b/vendor/github.com/spf13/cobra/command_win.go @@ -11,14 +11,8 @@ import ( var preExecHookFn = preExecHook -// enables an information splash screen on Windows if the CLI is started from explorer.exe. -var MousetrapHelpText string = `This is a command line tool - -You need to open cmd.exe and run it from there. -` - func preExecHook(c *Command) { - if mousetrap.StartedByExplorer() { + if MousetrapHelpText != "" && mousetrap.StartedByExplorer() { c.Print(MousetrapHelpText) time.Sleep(5 * time.Second) os.Exit(1)