mirror of
https://github.com/restic/rest-server.git
synced 2026-09-12 07:06:09 -07:00
Update dependencies
This commit is contained in:
Generated
+2
-2
@@ -4,7 +4,7 @@
|
|||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/gorilla/handlers"
|
name = "github.com/gorilla/handlers"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "a4d79d4487c2430a17d9dc8a1f74d1a6ed6908ca"
|
revision = "a4043c62cc2329bacda331d33fc908ab11ef0ec3"
|
||||||
source = "https://github.com/gorilla/handlers"
|
source = "https://github.com/gorilla/handlers"
|
||||||
version = "v1.2.1"
|
version = "v1.2.1"
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/spf13/cobra"
|
name = "github.com/spf13/cobra"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "4d647c8944eb42504a714e57e97f244ed6344722"
|
revision = "715f41bd7a70b5111f898b71ab484da52ee6266d"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
|||||||
-2
@@ -7,7 +7,6 @@ matrix:
|
|||||||
- go: 1.5
|
- go: 1.5
|
||||||
- go: 1.6
|
- go: 1.6
|
||||||
- go: 1.7
|
- go: 1.7
|
||||||
- go: 1.8
|
|
||||||
- go: tip
|
- go: tip
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- go: tip
|
- go: tip
|
||||||
@@ -17,4 +16,3 @@ script:
|
|||||||
- diff -u <(echo -n) <(gofmt -d .)
|
- diff -u <(echo -n) <(gofmt -d .)
|
||||||
- go vet $(go list ./... | grep -v /vendor/)
|
- go vet $(go list ./... | grep -v /vendor/)
|
||||||
- go test -v -race ./...
|
- go test -v -race ./...
|
||||||
|
|
||||||
|
|||||||
+9
@@ -47,6 +47,15 @@ var EnablePrefixMatching = false
|
|||||||
// To disable sorting, set it to false.
|
// To disable sorting, set it to false.
|
||||||
var EnableCommandSorting = true
|
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
|
// AddTemplateFunc adds a template function that's available to Usage and Help
|
||||||
// template generation.
|
// template generation.
|
||||||
func AddTemplateFunc(name string, tmplFunc interface{}) {
|
func AddTemplateFunc(name string, tmplFunc interface{}) {
|
||||||
|
|||||||
+14
-4
@@ -45,24 +45,34 @@ func er(msg interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// isEmpty checks if a given path is empty.
|
// isEmpty checks if a given path is empty.
|
||||||
|
// Hidden files in path are ignored.
|
||||||
func isEmpty(path string) bool {
|
func isEmpty(path string) bool {
|
||||||
fi, err := os.Stat(path)
|
fi, err := os.Stat(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
er(err)
|
er(err)
|
||||||
}
|
}
|
||||||
if fi.IsDir() {
|
|
||||||
|
if !fi.IsDir() {
|
||||||
|
return fi.Size() == 0
|
||||||
|
}
|
||||||
|
|
||||||
f, err := os.Open(path)
|
f, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
er(err)
|
er(err)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
dirs, err := f.Readdirnames(1)
|
|
||||||
|
names, err := f.Readdirnames(-1)
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
er(err)
|
er(err)
|
||||||
}
|
}
|
||||||
return len(dirs) == 0
|
|
||||||
|
for _, name := range names {
|
||||||
|
if len(name) > 0 && name[0] != '.' {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
return fi.Size() == 0
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// exists checks if a file or directory exists.
|
// exists checks if a file or directory exists.
|
||||||
|
|||||||
+3
-3
@@ -767,17 +767,16 @@ func (c *Command) InitDefaultHelpFlag() {
|
|||||||
// It is called automatically by executing the c or by calling help and usage.
|
// 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.
|
// If c already has help command or c has no subcommands, it will do nothing.
|
||||||
func (c *Command) InitDefaultHelpCmd() {
|
func (c *Command) InitDefaultHelpCmd() {
|
||||||
if c.helpCommand != nil || !c.HasSubCommands() {
|
if !c.HasSubCommands() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.helpCommand == nil {
|
||||||
c.helpCommand = &Command{
|
c.helpCommand = &Command{
|
||||||
Use: "help [command]",
|
Use: "help [command]",
|
||||||
Short: "Help about any command",
|
Short: "Help about any command",
|
||||||
Long: `Help provides help for any command in the application.
|
Long: `Help provides help for any command in the application.
|
||||||
Simply type ` + c.Name() + ` help [path to command] for full details.`,
|
Simply type ` + c.Name() + ` help [path to command] for full details.`,
|
||||||
PersistentPreRun: func(cmd *Command, args []string) {},
|
|
||||||
PersistentPostRun: func(cmd *Command, args []string) {},
|
|
||||||
|
|
||||||
Run: func(c *Command, args []string) {
|
Run: func(c *Command, args []string) {
|
||||||
cmd, _, e := c.Root().Find(args)
|
cmd, _, e := c.Root().Find(args)
|
||||||
@@ -790,6 +789,7 @@ func (c *Command) InitDefaultHelpCmd() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
}
|
||||||
c.RemoveCommand(c.helpCommand)
|
c.RemoveCommand(c.helpCommand)
|
||||||
c.AddCommand(c.helpCommand)
|
c.AddCommand(c.helpCommand)
|
||||||
}
|
}
|
||||||
|
|||||||
+35
-6
@@ -120,7 +120,6 @@ func TestStripFlags(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDisableFlagParsing(t *testing.T) {
|
func TestDisableFlagParsing(t *testing.T) {
|
||||||
as := []string{"-v", "-race", "-file", "foo.go"}
|
|
||||||
targs := []string{}
|
targs := []string{}
|
||||||
cmdPrint := &Command{
|
cmdPrint := &Command{
|
||||||
DisableFlagParsing: true,
|
DisableFlagParsing: true,
|
||||||
@@ -128,14 +127,14 @@ func TestDisableFlagParsing(t *testing.T) {
|
|||||||
targs = args
|
targs = args
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
osargs := []string{"cmd"}
|
args := []string{"cmd", "-v", "-race", "-file", "foo.go"}
|
||||||
os.Args = append(osargs, as...)
|
cmdPrint.SetArgs(args)
|
||||||
err := cmdPrint.Execute()
|
err := cmdPrint.Execute()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(as, targs) {
|
if !reflect.DeepEqual(args, targs) {
|
||||||
t.Errorf("expected: %v, got: %v", as, 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") {
|
if !strings.Contains(output.String(), "This flag is deprecated") {
|
||||||
t.Errorf("Expected to contain deprecated message, but got %q", output.String())
|
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())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-7
@@ -11,14 +11,8 @@ import (
|
|||||||
|
|
||||||
var preExecHookFn = preExecHook
|
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) {
|
func preExecHook(c *Command) {
|
||||||
if mousetrap.StartedByExplorer() {
|
if MousetrapHelpText != "" && mousetrap.StartedByExplorer() {
|
||||||
c.Print(MousetrapHelpText)
|
c.Print(MousetrapHelpText)
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user