rc: fix missing --rc flags

In this commit we accidentally removed the global --rc flags.

0df7466d2b cmd/rcd: Fix command docs to include command specific prefix (#6675)

This re-instates them.
This commit is contained in:
Nick Craig-Wood 2023-03-23 12:04:17 +00:00
parent 866600a73b
commit 48ec00cc1a
3 changed files with 10 additions and 9 deletions

View File

@ -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

View File

@ -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",
},

View File

@ -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)
}