Remove -r introduce ... as recursive keyword
This commit is contained in:
@@ -19,6 +19,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/cheggaaa/pb"
|
||||
"github.com/minio-io/cli"
|
||||
@@ -53,7 +54,12 @@ func runCopyCmd(ctx *cli.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
sourceURL := urls[0] // First arg is source
|
||||
sourceURL := urls[0] // First arg is source
|
||||
recursive := isURLRecursive(sourceURL)
|
||||
// if recursive strip off the "..."
|
||||
if recursive {
|
||||
sourceURL = strings.TrimSuffix(sourceURL, recursiveSeparator)
|
||||
}
|
||||
targetURLs := urls[1:] // 1 or more targets
|
||||
|
||||
sourceURLConfigMap := make(map[string]*hostConfig)
|
||||
@@ -70,8 +76,8 @@ func runCopyCmd(ctx *cli.Context) {
|
||||
console.Fatalf("mc: reading host configs failed with following reason: [%s]\n", iodine.ToError(err))
|
||||
}
|
||||
|
||||
// perform copy
|
||||
if ctx.Bool("recursive") {
|
||||
// perform recursive
|
||||
if recursive {
|
||||
errorMsg, err := doCopyCmdRecursive(mcClientManager{}, sourceURLConfigMap, targetURLConfigMap)
|
||||
err = iodine.New(err, nil)
|
||||
if err != nil {
|
||||
|
||||
+7
-13
@@ -27,16 +27,9 @@ import (
|
||||
// List of commands
|
||||
var (
|
||||
cpCmd = cli.Command{
|
||||
Name: "cp",
|
||||
Usage: "Copy objects and files",
|
||||
// Description: "Copy files and objects recursively across object storage and filesystems",
|
||||
Name: "cp",
|
||||
Usage: "Copy objects and files",
|
||||
Action: runCopyCmd,
|
||||
Flags: []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "Recursively crawl a given directory or bucket",
|
||||
},
|
||||
},
|
||||
CustomHelpTemplate: `NAME:
|
||||
mc {{.Name}} - {{.Usage}}
|
||||
|
||||
@@ -49,15 +42,16 @@ DESCRIPTION:
|
||||
OPTIONS:
|
||||
{{range .Flags}}{{.}}
|
||||
{{end}}{{ end }}
|
||||
|
||||
EXAMPLES:
|
||||
1. Copy an object from Amazon S3 object storage to local fileystem.
|
||||
$ mc {{.Name}} https://s3.amazonaws.com/jukebox/klingon_opera_aktuh_maylotah.ogg wakeup.ogg
|
||||
|
||||
2. Copy a bucket recursive from Minio object storage to Amazon S3 object storage
|
||||
$ mc {{.Name}} --recursive http://localhost:9000/photos/burningman2011 https://s3.amazonaws.com/burningman/
|
||||
2. Copy a bucket recursively from Minio object storage to Amazon S3 object storage
|
||||
$ mc {{.Name}} http://localhost:9000/photos/burningman2011... https://s3.amazonaws.com/burningman/
|
||||
|
||||
3. Copy a local folder to Minio object storage and Amazon S3 object storage
|
||||
$ mc {{.Name}} --recursive backup/ http://localhost:9000/archive/ https://s3.amazonaws.com/archive/
|
||||
3. Copy a local folder recursively to Minio object storage and Amazon S3 object storage
|
||||
$ mc {{.Name}} backup/... http://localhost:9000/archive/ https://s3.amazonaws.com/archive/
|
||||
|
||||
4. Copy an object from Amazon S3 object storage to local filesystem on Windows.
|
||||
$ mc {{.Name}} https://s3.amazonaws.com/jukebox/vulcan_lute.ogg C:\Users\Surak\sleep.ogg
|
||||
|
||||
@@ -18,11 +18,20 @@ package main
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/minio-io/mc/pkg/client"
|
||||
"github.com/minio-io/minio/pkg/iodine"
|
||||
)
|
||||
|
||||
const (
|
||||
recursiveSeparator = "..."
|
||||
)
|
||||
|
||||
func isURLRecursive(urlStr string) bool {
|
||||
return strings.HasSuffix(urlStr, recursiveSeparator)
|
||||
}
|
||||
|
||||
// getURL extracts URL string from a single cmd-line argument
|
||||
func getURL(arg string, aliases map[string]string) (urlStr string, err error) {
|
||||
_, err = url.Parse(arg)
|
||||
|
||||
Reference in New Issue
Block a user