Add ./mc cp to support <source1> <source2> <target>
This commit is contained in:
@@ -67,13 +67,39 @@ func runCopyCmdMultipleSources(methods clientMethods, urls []string) {
|
||||
console.Fatalf("Unable to read host configuration for the following targets %s from config file [%s]. Reason: [%s].\n",
|
||||
targetURL, mustGetMcConfigPath(), iodine.ToError(err))
|
||||
}
|
||||
sourceURLConfigMap, err := getHostConfigs(sourceURLs)
|
||||
var newRecursiveSourceURLs []string
|
||||
var newRegularSourceURLs []string
|
||||
for _, sourceURL := range sourceURLs {
|
||||
recursive := isURLRecursive(sourceURL)
|
||||
// if recursive strip off the "..."
|
||||
if recursive {
|
||||
sourceURL = strings.TrimSuffix(sourceURL, recursiveSeparator)
|
||||
newRecursiveSourceURLs = append(newRecursiveSourceURLs, sourceURL)
|
||||
} else {
|
||||
newRegularSourceURLs = append(newRegularSourceURLs, sourceURL)
|
||||
}
|
||||
}
|
||||
for _, newRecursiveSourceURL := range newRecursiveSourceURLs {
|
||||
newRecursiveSourceConfig, err := getHostConfig(newRecursiveSourceURL)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read host configuration for the following targets %s from config file [%s]. Reason: [%s].\n",
|
||||
newRecursiveSourceURL, mustGetMcConfigPath(), iodine.ToError(err))
|
||||
}
|
||||
err = doCopySingleSourceRecursive(methods, newRecursiveSourceURL, targetURL, newRecursiveSourceConfig, targetConfig)
|
||||
if err != nil {
|
||||
log.Debug.Println(err)
|
||||
console.Fatalf("Failed to copy from source [%s] to target %s. Reason: [%s].\n", newRecursiveSourceURL,
|
||||
targetURL, iodine.ToError(err))
|
||||
}
|
||||
}
|
||||
newRegularSourceURLConfigMap, err := getHostConfigs(newRegularSourceURLs)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read host configuration for source [%s] from config file [%s]. Reason: [%s].\n",
|
||||
sourceURLs, mustGetMcConfigPath(), iodine.ToError(err))
|
||||
}
|
||||
err = doCopyMultipleSources(methods, sourceURLConfigMap, targetURL, targetConfig)
|
||||
err = doCopyMultipleSources(methods, newRegularSourceURLConfigMap, targetURL, targetConfig)
|
||||
if err != nil {
|
||||
log.Debug.Println(err)
|
||||
console.Fatalf("Failed to copy from source [%s] to target %s. Reason: [%s].\n", sourceURLs, targetURL, iodine.ToError(err))
|
||||
|
||||
+25
-2
@@ -86,7 +86,7 @@ EXAMPLES:
|
||||
}
|
||||
cpCmd = cli.Command{
|
||||
Name: "cp",
|
||||
Usage: "Copy objects and files",
|
||||
Usage: "Copy objects and files from multiple sources single destination",
|
||||
Action: runCopyCmd,
|
||||
CustomHelpTemplate: `NAME:
|
||||
mc {{.Name}} - {{.Usage}}
|
||||
@@ -165,6 +165,27 @@ EXAMPLES:
|
||||
`,
|
||||
}
|
||||
|
||||
syncCmd = cli.Command{
|
||||
Name: "sync",
|
||||
Usage: "Copies files and objects from single source to multiple destinations",
|
||||
Action: runSyncCmd,
|
||||
CustomHelpTemplate: `NAME:
|
||||
mc {{.Name}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
mc {{.Name}} TARGET [TARGET...] {{if .Description}}
|
||||
|
||||
DESCRIPTION:
|
||||
{{.Description}}{{end}}{{if .Flags}}
|
||||
|
||||
FLAGS:
|
||||
{{range .Flags}}{{.}}
|
||||
{{end}}{{ end }}
|
||||
|
||||
EXAMPLES:
|
||||
|
||||
`,
|
||||
}
|
||||
mbCmd = cli.Command{
|
||||
Name: "mb",
|
||||
Usage: "Make a directory or bucket",
|
||||
@@ -247,7 +268,8 @@ EXAMPLES:
|
||||
//
|
||||
// ----
|
||||
// ls List files and objects
|
||||
// cp Copy objects and files
|
||||
// cp Copy objects and files from multiple sources to single destination
|
||||
// sync Copy objects and files from single source to multiple destionations
|
||||
// mb Make a bucket
|
||||
// access Set permissions [public, private, readonly] for buckets and folders.
|
||||
// cat Concantenate an object to standard output
|
||||
@@ -258,6 +280,7 @@ EXAMPLES:
|
||||
var commands = []cli.Command{
|
||||
lsCmd,
|
||||
cpCmd,
|
||||
syncCmd,
|
||||
catCmd,
|
||||
mbCmd,
|
||||
accessCmd,
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package main
|
||||
|
||||
import "github.com/minio-io/cli"
|
||||
|
||||
func runSyncCmd(ctx *cli.Context) {
|
||||
}
|
||||
Reference in New Issue
Block a user