diff --git a/cmd/help.go b/cmd/help.go index c0371089a..ecc34b63e 100644 --- a/cmd/help.go +++ b/cmd/help.go @@ -13,6 +13,7 @@ import ( "github.com/rclone/rclone/fs/config/configflags" "github.com/rclone/rclone/fs/filter/filterflags" "github.com/rclone/rclone/fs/log/logflags" + "github.com/rclone/rclone/fs/rc/rcflags" "github.com/rclone/rclone/lib/atexit" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -173,6 +174,7 @@ func setupRootCommand(rootCmd *cobra.Command) { // Add global flags configflags.AddFlags(ci, pflag.CommandLine) filterflags.AddFlags(pflag.CommandLine) + rcflags.AddFlags(pflag.CommandLine) logflags.AddFlags(pflag.CommandLine) Root.Run = runRoot diff --git a/cmd/rcd/rcd.go b/cmd/rcd/rcd.go index 542a287b0..8e90240d1 100644 --- a/cmd/rcd/rcd.go +++ b/cmd/rcd/rcd.go @@ -15,11 +15,7 @@ import ( "github.com/spf13/cobra" ) -// flagPrefix is the prefix used to uniquely identify command line flags. -const flagPrefix = "rc-" - func init() { - rcflags.AddFlags(cmd.Root.Flags(), flagPrefix) cmd.Root.AddCommand(commandDefinition) } @@ -36,7 +32,7 @@ for GET requests on the URL passed in. It will also open the URL in the browser when rclone is run. See the [rc documentation](/rc/) for more info on the rc flags. -` + libhttp.Help(flagPrefix) + libhttp.TemplateHelp(flagPrefix) + libhttp.AuthHelp(flagPrefix), +` + libhttp.Help(rcflags.FlagPrefix) + libhttp.TemplateHelp(rcflags.FlagPrefix) + libhttp.AuthHelp(rcflags.FlagPrefix), Annotations: map[string]string{ "versionIntroduced": "v1.45", }, diff --git a/fs/rc/rcflags/rcflags.go b/fs/rc/rcflags/rcflags.go index b51e7bf3f..f323806c8 100644 --- a/fs/rc/rcflags/rcflags.go +++ b/fs/rc/rcflags/rcflags.go @@ -7,13 +7,16 @@ import ( "github.com/spf13/pflag" ) +// FlagPrefix is the prefix used to uniquely identify command line flags. +const FlagPrefix = "rc-" + // Options set by command line flags var ( Opt = rc.DefaultOpt ) // AddFlags adds the remote control flags to the flagSet -func AddFlags(flagSet *pflag.FlagSet, commonFlagPrefix string) { +func AddFlags(flagSet *pflag.FlagSet) { rc.AddOption("rc", &Opt) flags.BoolVarP(flagSet, &Opt.Enabled, "rc", "", false, "Enable the remote control server") flags.StringVarP(flagSet, &Opt.Files, "rc-files", "", "", "Path to local files to serve on the HTTP server") @@ -28,7 +31,7 @@ func AddFlags(flagSet *pflag.FlagSet, commonFlagPrefix string) { flags.BoolVarP(flagSet, &Opt.EnableMetrics, "rc-enable-metrics", "", false, "Enable prometheus metrics on /metrics") flags.DurationVarP(flagSet, &Opt.JobExpireDuration, "rc-job-expire-duration", "", Opt.JobExpireDuration, "Expire finished async jobs older than this value") flags.DurationVarP(flagSet, &Opt.JobExpireInterval, "rc-job-expire-interval", "", Opt.JobExpireInterval, "Interval to check for expired async jobs") - Opt.HTTP.AddFlagsPrefix(flagSet, commonFlagPrefix) - Opt.Auth.AddFlagsPrefix(flagSet, commonFlagPrefix) - Opt.Template.AddFlagsPrefix(flagSet, commonFlagPrefix) + Opt.HTTP.AddFlagsPrefix(flagSet, FlagPrefix) + Opt.Auth.AddFlagsPrefix(flagSet, FlagPrefix) + Opt.Template.AddFlagsPrefix(flagSet, FlagPrefix) }