Permalink
Browse files

Allow all options to be set from environment variables

The option names are munged changing - to _ making upper case and
prepending RCLONE_.  The values are as parsed by pflag.
  • Loading branch information...
1 parent 3b0f944 commit 0d75d2585f09b3518da54e44960173844181199d @ncw committed Dec 20, 2016
Showing with 571 additions and 478 deletions.
  1. +2 −3 amazonclouddrive/amazonclouddrive.go
  2. +4 −5 b2/b2.go
  3. +6 −6 cmd/cmd.go
  4. +6 −7 drive/drive.go
  5. +1 −2 dropbox/dropbox.go
  6. +30 −251 fs/config.go
  7. +0 −179 fs/config_test.go
  8. +14 −15 fs/filter.go
  9. +315 −0 fs/flags.go
  10. +187 −0 fs/flags_test.go
  11. +1 −2 local/read_device_unix.go
  12. +2 −3 onedrive/onedrive.go
  13. +2 −3 s3/s3.go
  14. +1 −2 swift/swift.go
@@ -31,7 +31,6 @@ import (
"github.com/ncw/rclone/pacer"
"github.com/ncw/rclone/rest"
"github.com/pkg/errors"
- "github.com/spf13/pflag"
"golang.org/x/oauth2"
)
@@ -51,7 +50,7 @@ const (
var (
// Flags
tempLinkThreshold = fs.SizeSuffix(9 << 30) // Download files bigger than this via the tempLink
- uploadWaitPerGB = pflag.DurationP("acd-upload-wait-per-gb", "", 180*time.Second, "Additional time per GB to wait after a failed complete upload to see if it appears.")
+ uploadWaitPerGB = fs.DurationP("acd-upload-wait-per-gb", "", 180*time.Second, "Additional time per GB to wait after a failed complete upload to see if it appears.")
// Description of how to auth for this app
acdConfig = &oauth2.Config{
Scopes: []string{"clouddrive:read_all", "clouddrive:write"},
@@ -85,7 +84,7 @@ func init() {
Help: "Amazon Application Client Secret - leave blank normally.",
}},
})
- pflag.VarP(&tempLinkThreshold, "acd-templink-threshold", "", "Files >= this size will be downloaded via their tempLink.")
+ fs.VarP(&tempLinkThreshold, "acd-templink-threshold", "", "Files >= this size will be downloaded via their tempLink.")
}
// Fs represents a remote acd server
View
@@ -25,7 +25,6 @@ import (
"github.com/ncw/rclone/pacer"
"github.com/ncw/rclone/rest"
"github.com/pkg/errors"
- "github.com/spf13/pflag"
)
const (
@@ -50,8 +49,8 @@ var (
minChunkSize = fs.SizeSuffix(100E6)
chunkSize = fs.SizeSuffix(96 * 1024 * 1024)
uploadCutoff = fs.SizeSuffix(200E6)
- b2TestMode = pflag.StringP("b2-test-mode", "", "", "A flag string for X-Bz-Test-Mode header.")
- b2Versions = pflag.BoolP("b2-versions", "", false, "Include old versions in directory listings.")
+ b2TestMode = fs.StringP("b2-test-mode", "", "", "A flag string for X-Bz-Test-Mode header.")
+ b2Versions = fs.BoolP("b2-versions", "", false, "Include old versions in directory listings.")
errNotWithVersions = errors.New("can't modify or delete files in --b2-versions mode")
)
@@ -73,8 +72,8 @@ func init() {
},
},
})
- pflag.VarP(&uploadCutoff, "b2-upload-cutoff", "", "Cutoff for switching to chunked upload")
- pflag.VarP(&chunkSize, "b2-chunk-size", "", "Upload chunk size. Must fit in memory.")
+ fs.VarP(&uploadCutoff, "b2-upload-cutoff", "", "Cutoff for switching to chunked upload")
+ fs.VarP(&chunkSize, "b2-chunk-size", "", "Upload chunk size. Must fit in memory.")
}
// Fs represents a remote b2 server
View
@@ -26,13 +26,13 @@ import (
// Globals
var (
// Flags
- cpuProfile = pflag.StringP("cpuprofile", "", "", "Write cpu profile to file")
- memProfile = pflag.String("memprofile", "", "Write memory profile to file")
- statsInterval = pflag.DurationP("stats", "", time.Minute*1, "Interval between printing stats, e.g 500ms, 60s, 5m. (0 to disable)")
- dataRateUnit = pflag.StringP("stats-unit", "", "bytes", "Show data rate in stats as either 'bits' or 'bytes'/s")
+ cpuProfile = fs.StringP("cpuprofile", "", "", "Write cpu profile to file")
+ memProfile = fs.StringP("memprofile", "", "", "Write memory profile to file")
+ statsInterval = fs.DurationP("stats", "", time.Minute*1, "Interval between printing stats, e.g 500ms, 60s, 5m. (0 to disable)")
+ dataRateUnit = fs.StringP("stats-unit", "", "bytes", "Show data rate in stats as either 'bits' or 'bytes'/s")
version bool
- logFile = pflag.StringP("log-file", "", "", "Log everything to this file")
- retries = pflag.IntP("retries", "", 3, "Retry operations this many times if they fail")
+ logFile = fs.StringP("log-file", "", "", "Log everything to this file")
+ retries = fs.IntP("retries", "", 3, "Retry operations this many times if they fail")
)
// Root is the main rclone command
View
@@ -21,7 +21,6 @@ import (
"github.com/ncw/rclone/oauthutil"
"github.com/ncw/rclone/pacer"
"github.com/pkg/errors"
- "github.com/spf13/pflag"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"google.golang.org/api/drive/v2"
@@ -42,10 +41,10 @@ const (
// Globals
var (
// Flags
- driveFullList = pflag.BoolP("drive-full-list", "", false, "Use a full listing for directory list. More data but usually quicker. (obsolete)")
- driveAuthOwnerOnly = pflag.BoolP("drive-auth-owner-only", "", false, "Only consider files owned by the authenticated user. Requires drive-full-list.")
- driveUseTrash = pflag.BoolP("drive-use-trash", "", false, "Send files to the trash instead of deleting permanently.")
- driveExtensions = pflag.StringP("drive-formats", "", defaultExtensions, "Comma separated list of preferred formats for downloading Google docs.")
+ driveFullList = fs.BoolP("drive-full-list", "", false, "Use a full listing for directory list. More data but usually quicker. (obsolete)")
+ driveAuthOwnerOnly = fs.BoolP("drive-auth-owner-only", "", false, "Only consider files owned by the authenticated user. Requires drive-full-list.")
+ driveUseTrash = fs.BoolP("drive-use-trash", "", false, "Send files to the trash instead of deleting permanently.")
+ driveExtensions = fs.StringP("drive-formats", "", defaultExtensions, "Comma separated list of preferred formats for downloading Google docs.")
// chunkSize is the size of the chunks created during a resumable upload and should be a power of two.
// 1<<18 is the minimum size supported by the Google uploader, and there is no maximum.
chunkSize = fs.SizeSuffix(8 * 1024 * 1024)
@@ -103,8 +102,8 @@ func init() {
Help: "Google Application Client Secret - leave blank normally.",
}},
})
- pflag.VarP(&driveUploadCutoff, "drive-upload-cutoff", "", "Cutoff for switching to chunked upload")
- pflag.VarP(&chunkSize, "drive-chunk-size", "", "Upload chunk size. Must a power of 2 >= 256k.")
+ fs.VarP(&driveUploadCutoff, "drive-upload-cutoff", "", "Cutoff for switching to chunked upload")
+ fs.VarP(&chunkSize, "drive-chunk-size", "", "Upload chunk size. Must a power of 2 >= 256k.")
// Invert mimeTypeToExtension
extensionToMimeType = make(map[string]string, len(mimeTypeToExtension))
View
@@ -22,7 +22,6 @@ import (
"github.com/ncw/rclone/fs"
"github.com/ncw/rclone/oauthutil"
"github.com/pkg/errors"
- "github.com/spf13/pflag"
"github.com/stacktic/dropbox"
)
@@ -58,7 +57,7 @@ func init() {
Help: "Dropbox App Secret - leave blank normally.",
}},
})
- pflag.VarP(&uploadChunkSize, "dropbox-chunk-size", "", fmt.Sprintf("Upload chunk size. Max %v.", maxUploadChunkSize))
+ fs.VarP(&uploadChunkSize, "dropbox-chunk-size", "", fmt.Sprintf("Upload chunk size. Max %v.", maxUploadChunkSize))
}
// Configuration helper - called after the user has put in the defaults
Oops, something went wrong.

0 comments on commit 0d75d25

Please sign in to comment.