diff --git a/commands.go b/commands.go index 819eb00..d5340bd 100644 --- a/commands.go +++ b/commands.go @@ -370,8 +370,12 @@ func NewUploadCommand() cli.Command { if c.Int("w") > 10 || c.Int("w") < 1 { PrintErrorAndExit("max concurrent threads must between (1 - 10)") } + filenames := c.Args() + if isWindowsGOOS() { + filenames = globFiles(filenames) + } session.Upload( - c.Args(), + filenames, c.String("remote"), c.Int("w"), c.Bool("all"), diff --git a/utils.go b/utils.go index 28d9906..3ead06a 100644 --- a/utils.go +++ b/utils.go @@ -5,6 +5,8 @@ import ( "fmt" "io" "os" + "path/filepath" + "runtime" "strconv" "strings" "time" @@ -140,3 +142,20 @@ func contains(slice []string, item string) bool { } return false } + +func globFiles(patterns []string) []string { + filenames := make([]string, 0) + for _, filename := range patterns { + if strings.Contains(filename, "*") { + matches, err := filepath.Glob(filename) + if err == nil { + filenames = append(filenames, matches...) + } + } + } + return filenames +} + +func isWindowsGOOS() bool { + return runtime.GOOS == "windows" +}