rc: add options/local to see the options configured in the context

This commit is contained in:
Nick Craig-Wood 2020-12-12 16:55:57 +00:00
parent 8574a7bd67
commit 9a21aff4ed
1 changed files with 37 additions and 1 deletions

View File

@ -8,6 +8,8 @@ import (
"context"
"github.com/pkg/errors"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/filter"
)
var (
@ -52,10 +54,14 @@ func init() {
Add(Call{
Path: "options/get",
Fn: rcOptionsGet,
Title: "Get all the options",
Title: "Get all the global options",
Help: `Returns an object where keys are option block names and values are an
object with the current option values in.
Note that these are the global options which are unaffected by use of
the _config and _filter parameters. If you wish to read the parameters
set in _config then use options/config and for _filter use options/filter.
This shows the internal names of the option within rclone which should
map to the external options very easily with a few exceptions.
`,
@ -71,6 +77,36 @@ func rcOptionsGet(ctx context.Context, in Params) (out Params, err error) {
return out, nil
}
func init() {
Add(Call{
Path: "options/local",
Fn: rcOptionsLocal,
Title: "Get the currently active config for this call",
Help: `Returns an object with the keys "config" and "filter".
The "config" key contains the local config and the "filter" key contains
the local filters.
Note that these are the local options specific to this rc call. If
_config was not supplied then they will be the global options.
Likewise with "_filter".
This call is mostly useful for seeing if _config and _filter passing
is working.
This shows the internal names of the option within rclone which should
map to the external options very easily with a few exceptions.
`,
})
}
// Show the current config
func rcOptionsLocal(ctx context.Context, in Params) (out Params, err error) {
out = make(Params)
out["config"] = fs.GetConfig(ctx)
out["filter"] = filter.GetConfig(ctx)
return out, nil
}
func init() {
Add(Call{
Path: "options/set",