From 63e6d9d2d161b290cf86c977eb9226c424458462 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 10 Jun 2020 17:33:55 +0100 Subject: [PATCH] serve webdav,serve restic: Fix flags so they use environment variables See: https://forum.rclone.org/t/serve-restic-append-only-environment-variable/17050 --- cmd/serve/restic/restic.go | 8 +++++--- cmd/serve/webdav/webdav.go | 12 +++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cmd/serve/restic/restic.go b/cmd/serve/restic/restic.go index aebbd4138..f19b1d37c 100644 --- a/cmd/serve/restic/restic.go +++ b/cmd/serve/restic/restic.go @@ -17,6 +17,7 @@ import ( "github.com/rclone/rclone/cmd/serve/httplib/serve" "github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs/accounting" + "github.com/rclone/rclone/fs/config/flags" "github.com/rclone/rclone/fs/fserrors" "github.com/rclone/rclone/fs/operations" "github.com/rclone/rclone/fs/walk" @@ -33,9 +34,10 @@ var ( func init() { httpflags.AddFlags(Command.Flags()) - Command.Flags().BoolVar(&stdio, "stdio", false, "run an HTTP2 server on stdin/stdout") - Command.Flags().BoolVar(&appendOnly, "append-only", false, "disallow deletion of repository data") - Command.Flags().BoolVar(&privateRepos, "private-repos", false, "users can only access their private repo") + flagSet := Command.Flags() + flags.BoolVarP(flagSet, &stdio, "stdio", "", false, "run an HTTP2 server on stdin/stdout") + flags.BoolVarP(flagSet, &appendOnly, "append-only", "", false, "disallow deletion of repository data") + flags.BoolVarP(flagSet, &privateRepos, "private-repos", "", false, "users can only access their private repo") } // Command definition for cobra diff --git a/cmd/serve/webdav/webdav.go b/cmd/serve/webdav/webdav.go index 377b17ba8..37cc34860 100644 --- a/cmd/serve/webdav/webdav.go +++ b/cmd/serve/webdav/webdav.go @@ -15,6 +15,7 @@ import ( "github.com/rclone/rclone/cmd/serve/proxy" "github.com/rclone/rclone/cmd/serve/proxy/proxyflags" "github.com/rclone/rclone/fs" + "github.com/rclone/rclone/fs/config/flags" "github.com/rclone/rclone/fs/hash" "github.com/rclone/rclone/lib/errors" "github.com/rclone/rclone/vfs" @@ -30,11 +31,12 @@ var ( ) func init() { - httpflags.AddFlags(Command.Flags()) - vfsflags.AddFlags(Command.Flags()) - proxyflags.AddFlags(Command.Flags()) - Command.Flags().StringVar(&hashName, "etag-hash", "", "Which hash to use for the ETag, or auto or blank for off") - Command.Flags().BoolVar(&disableGETDir, "disable-dir-list", false, "Disable HTML directory list on GET request for a directory") + flagSet := Command.Flags() + httpflags.AddFlags(flagSet) + vfsflags.AddFlags(flagSet) + proxyflags.AddFlags(flagSet) + flags.StringVarP(flagSet, &hashName, "etag-hash", "", "", "Which hash to use for the ETag, or auto or blank for off") + flags.BoolVarP(flagSet, &disableGETDir, "disable-dir-list", "", false, "Disable HTML directory list on GET request for a directory") } // Command definition for cobra