Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

vendor: update spf13/cobra to fix arg parsing

Nick Craig-Wood0c92a64bb360
diff --git a/Gopkg.lock b/Gopkg.lock
index 894d4da5a..ff1fd8f56 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -142,7 +142,7 @@ memo = "0c86c911e62d7207fb8549d69519a5a795ce4b36aadce87b84504f109eefe60b"
branch = "master"
name = "github.com/spf13/cobra"
packages = [".","doc"]
- revision = "1362f95a8d6fe330d00a64380d6e0b65f4992c72"
+ revision = "90687e7bfc7e1e5cd88eb1f513f32f01dc03dd7c"
[[projects]]
branch = "master"
diff --git a/vendor/github.com/spf13/cobra/README.md b/vendor/github.com/spf13/cobra/README.md
index b45f401eb..4563c211d 100644
--- a/vendor/github.com/spf13/cobra/README.md
+++ b/vendor/github.com/spf13/cobra/README.md
@@ -114,7 +114,7 @@ and flags that are only available to that command.
In the example above, 'port' is the flag.
Flag functionality is provided by the [pflag
-library](https://github.com/ogier/pflag), a fork of the flag standard library
+library](https://github.com/spf13/pflag), a fork of the flag standard library
which maintains the same interface while adding POSIX compliance.
## Usage
diff --git a/vendor/github.com/spf13/cobra/bash_completions.md b/vendor/github.com/spf13/cobra/bash_completions.md
index 7fa970fa2..52bd39ddb 100644
--- a/vendor/github.com/spf13/cobra/bash_completions.md
+++ b/vendor/github.com/spf13/cobra/bash_completions.md
@@ -106,7 +106,7 @@ node pod replicationcontroller service
If your nouns have a number of aliases, you can define them alongside `ValidArgs` using `ArgAliases`:
-```go`
+```go
argAliases []string = { "pods", "nodes", "services", "svc", "replicationcontrollers", "rc" }
cmd := &cobra.Command{
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/add.go b/vendor/github.com/spf13/cobra/cobra/cmd/add.go
index 20c6538c7..8897f8ff0 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/add.go
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/add.go
@@ -20,7 +20,6 @@ import (
"unicode"
"github.com/spf13/cobra"
- "github.com/spf13/viper"
)
func init() {
@@ -117,7 +116,7 @@ func createCmdFile(license License, path, cmdName string) {
template := `{{comment .copyright}}
{{comment .license}}
-package cmd
+package {{.cmdPackage}}
import (
"fmt"
@@ -158,7 +157,7 @@ func init() {
data := make(map[string]interface{})
data["copyright"] = copyrightLine()
data["license"] = license.Header
- data["viper"] = viper.GetBool("useViper")
+ data["cmdPackage"] = filepath.Base(filepath.Dir(path)) // last dir of path
data["parentName"] = parentName
data["cmdName"] = cmdName
diff --git a/vendor/github.com/spf13/cobra/cobra_test.go b/vendor/github.com/spf13/cobra/cobra_test.go
index 6f3ceb135..fcba20996 100644
--- a/vendor/github.com/spf13/cobra/cobra_test.go
+++ b/vendor/github.com/spf13/cobra/cobra_test.go
@@ -1150,12 +1150,12 @@ func TestGlobalNormFuncPropagation(t *testing.T) {
func TestFlagOnPflagCommandLine(t *testing.T) {
flagName := "flagOnCommandLine"
- pflag.CommandLine.String(flagName, "", "about my flag")
+ pflag.String(flagName, "", "about my flag")
r := fullSetupTest("--help")
checkResultContains(t, r, flagName)
- // reset CommandLine flagset
+ // Reset pflag.CommandLine flagset.
pflag.CommandLine = pflag.NewFlagSet(os.Args[0], pflag.ExitOnError)
}
diff --git a/vendor/github.com/spf13/cobra/command.go b/vendor/github.com/spf13/cobra/command.go
index 9e6bdf30e..3be55544e 100644
--- a/vendor/github.com/spf13/cobra/command.go
+++ b/vendor/github.com/spf13/cobra/command.go
@@ -1275,8 +1275,8 @@ func (c *Command) Parent() *Command {
// mergePersistentFlags merges c.PersistentFlags() to c.Flags()
// and adds missing persistent flags of all parents.
func (c *Command) mergePersistentFlags() {
- c.Flags().AddFlagSet(c.PersistentFlags())
c.updateParentsPflags()
+ c.Flags().AddFlagSet(c.PersistentFlags())
c.Flags().AddFlagSet(c.parentsPflags)
}
diff --git a/vendor/github.com/spf13/cobra/command_test.go b/vendor/github.com/spf13/cobra/command_test.go
index 24abd3e7e..978bacc52 100644
--- a/vendor/github.com/spf13/cobra/command_test.go
+++ b/vendor/github.com/spf13/cobra/command_test.go
@@ -227,7 +227,7 @@ func TestFlagErrorFunc(t *testing.T) {
// TestSortedFlags checks,
// if cmd.LocalFlags() is unsorted when cmd.Flags().SortFlags set to false.
-// https://github.com/spf13/cobra/issues/404
+// Related to https://github.com/spf13/cobra/issues/404.
func TestSortedFlags(t *testing.T) {
cmd := &Command{}
cmd.Flags().SortFlags = false
@@ -263,13 +263,13 @@ func isStringInStringSlice(s string, ss []string) bool {
// TestHelpFlagInHelp checks,
// if '--help' flag is shown in help for child (executing `parent help child`),
// that has no other flags.
-// https://github.com/spf13/cobra/issues/302
+// Related to https://github.com/spf13/cobra/issues/302.
func TestHelpFlagInHelp(t *testing.T) {
output := new(bytes.Buffer)
- parent := &Command{Use: "parent", Long: "long", Run: func(*Command, []string) { return }}
+ parent := &Command{Use: "parent", Run: func(*Command, []string) {}}
parent.SetOutput(output)
- child := &Command{Use: "child", Long: "long", Run: func(*Command, []string) { return }}
+ child := &Command{Use: "child", Run: func(*Command, []string) {}}
parent.AddCommand(child)
parent.SetArgs([]string{"help", "child"})
@@ -279,6 +279,22 @@ func TestHelpFlagInHelp(t *testing.T) {
}
if !strings.Contains(output.String(), "[flags]") {
- t.Fatalf("\nExpecting to contain: %v\nGot: %v", "[flags]", output.String())
+ t.Errorf("\nExpecting to contain: %v\nGot: %v", "[flags]", output.String())
}
}
+
+// TestMergeCommandLineToFlags checks,
+// if pflag.CommandLine is correctly merged to c.Flags() after first call
+// of c.mergePersistentFlags.
+// Related to https://github.com/spf13/cobra/issues/443.
+func TestMergeCommandLineToFlags(t *testing.T) {
+ pflag.Bool("boolflag", false, "")
+ c := &Command{Use: "c", Run: func(*Command, []string) {}}
+ c.mergePersistentFlags()
+ if c.Flags().Lookup("boolflag") == nil {
+ t.Fatal("Expecting to have flag from CommandLine in c.Flags()")
+ }
+
+ // Reset pflag.CommandLine flagset.
+ pflag.CommandLine = pflag.NewFlagSet(os.Args[0], pflag.ExitOnError)
+}