"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
Use pflag for gnu style flags
Nick Craig-Wooda628bef9c277
diff --git a/drive/drive.go b/drive/drive.goindex 10e36de2a..965289768 100644--- a/drive/drive.go+++ b/drive/drive.go@@ -17,7 +17,6 @@ package driveimport ("encoding/json"- "flag""fmt""io""log"@@ -31,6 +30,7 @@ import ("code.google.com/p/goauth2/oauth""code.google.com/p/google-api-go-client/drive/v2""github.com/ncw/rclone/fs"+ "github.com/ogier/pflag")// Constants@@ -43,7 +43,7 @@ const (// Globalsvar (// Flags- driveFullList = flag.Bool("drive-full-list", true, "Use a full listing for directory list. More data but usually quicker.")+ driveFullList = pflag.BoolP("drive-full-list", "", true, "Use a full listing for directory list. More data but usually quicker."))// Register with Fsdiff --git a/fs/config.go b/fs/config.goindex 01b5bc019..6e481dae2 100644--- a/fs/config.go+++ b/fs/config.go@@ -3,7 +3,6 @@ package fsimport ("bufio"- "flag""fmt""log""os"@@ -15,6 +14,7 @@ import ("time""github.com/Unknwon/goconfig"+ "github.com/ogier/pflag")const (@@ -32,12 +32,12 @@ var (// Global configConfig = &ConfigInfo{}// Flags- verbose = flag.Bool("verbose", false, "Print lots more stuff")- quiet = flag.Bool("quiet", false, "Print as little stuff as possible")- modifyWindow = flag.Duration("modify-window", time.Nanosecond, "Max time diff to be considered the same")- checkers = flag.Int("checkers", 8, "Number of checkers to run in parallel.")- transfers = flag.Int("transfers", 4, "Number of file transfers to run in parallel.")- configFile = flag.String("config", ConfigPath, "Config file.")+ verbose = pflag.BoolP("verbose", "v", false, "Print lots more stuff")+ quiet = pflag.BoolP("quiet", "q", false, "Print as little stuff as possible")+ modifyWindow = pflag.DurationP("modify-window", "", time.Nanosecond, "Max time diff to be considered the same")+ checkers = pflag.IntP("checkers", "", 8, "Number of checkers to run in parallel.")+ transfers = pflag.IntP("transfers", "", 4, "Number of file transfers to run in parallel.")+ configFile = pflag.StringP("config", "", ConfigPath, "Config file."))// Filesystem config optionsdiff --git a/rclone.go b/rclone.goindex 090d5a611..c6bb36134 100644--- a/rclone.go+++ b/rclone.go@@ -4,7 +4,6 @@package mainimport (- "flag""fmt""log""os"@@ -14,6 +13,8 @@ import ("sync""time"+ "github.com/ogier/pflag"+"github.com/ncw/rclone/fs"// Active file systems_ "github.com/ncw/rclone/drive"@@ -25,9 +26,9 @@ import (// Globalsvar (// Flags- cpuprofile = flag.String("cpuprofile", "", "Write cpu profile to file")- dry_run = flag.Bool("dry-run", false, "Do a trial run with no permanent changes")- statsInterval = flag.Duration("stats", time.Minute*1, "Interval to print stats")+ cpuprofile = pflag.StringP("cpuprofile", "", "", "Write cpu profile to file")+ dry_run = pflag.BoolP("dry-run", "n", false, "Do a trial run with no permanent changes")+ statsInterval = pflag.DurationP("stats", "", time.Minute*1, "Interval to print stats"))// A pair of fs.Objects@@ -131,7 +132,7 @@ func DeleteFiles(to_be_deleted fs.ObjectsChan) {defer wg.Done()for dst := range to_be_deleted {if *dry_run {- fs.Debug(dst, "Not deleting as -dry-run")+ fs.Debug(dst, "Not deleting as --dry-run")} else {fs.Stats.Checking(dst)err := dst.Remove()@@ -339,7 +340,7 @@ func mkdir(fdst, fsrc fs.Fs) {// Removes a container but not if not emptyfunc rmdir(fdst, fsrc fs.Fs) {if *dry_run {- log.Printf("Not deleting %s as -dry-run", fdst)+ log.Printf("Not deleting %s as --dry-run", fdst)} else {err := fdst.Rmdir()if err != nil {@@ -414,7 +415,7 @@ var Commands = []Command{unchanged files, testing first by modification time then byMD5SUM. Deletes any files that exist in source that don'texist in destination. Since this can cause data loss, test- first with the -dry-run flag.`,+ first with the --dry-run flag.`,Run: Sync,MinArgs: 2,MaxArgs: 2,@@ -507,7 +508,7 @@ Subcommands:}fmt.Fprintf(os.Stderr, "Options:\n")- flag.PrintDefaults()+ pflag.PrintDefaults()fmt.Fprintf(os.Stderr, `It is only necessary to use a unique prefix of the subcommand, eg 'up' for 'upload'.`)@@ -521,9 +522,9 @@ func fatal(message string, args ...interface{}) {}func main() {- flag.Usage = syntaxError- flag.Parse()- args := flag.Args()+ pflag.Usage = syntaxError+ pflag.Parse()+ args := pflag.Args()runtime.GOMAXPROCS(runtime.NumCPU())fs.LoadConfig()