mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
rc: add options/info call to enumerate options
This also makes some fields in the Options block optional - these are documented in rc.md
This commit is contained in:
@@ -12,19 +12,6 @@ import (
|
||||
"github.com/rclone/rclone/fs/filter"
|
||||
)
|
||||
|
||||
// AddOption adds an option set
|
||||
func AddOption(name string, option interface{}) {
|
||||
// FIXME remove this function when conversion to options is complete
|
||||
fs.RegisterGlobalOptions(fs.OptionsInfo{Name: name, Opt: option})
|
||||
}
|
||||
|
||||
// AddOptionReload adds an option set with a reload function to be
|
||||
// called when options are changed
|
||||
func AddOptionReload(name string, option interface{}, reload func(context.Context) error) {
|
||||
// FIXME remove this function when conversion to options is complete
|
||||
fs.RegisterGlobalOptions(fs.OptionsInfo{Name: name, Opt: option, Reload: reload})
|
||||
}
|
||||
|
||||
func init() {
|
||||
Add(Call{
|
||||
Path: "options/blocks",
|
||||
@@ -73,6 +60,29 @@ func rcOptionsGet(ctx context.Context, in Params) (out Params, err error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
Add(Call{
|
||||
Path: "options/info",
|
||||
Fn: rcOptionsInfo,
|
||||
Title: "Get info about all the global options",
|
||||
Help: `Returns an object where keys are option block names and values are an
|
||||
array of objects with info about each options.
|
||||
|
||||
These objects are in the same format as returned by "config/providers". They are
|
||||
described in the [option blocks](#option-blocks) section.
|
||||
`,
|
||||
})
|
||||
}
|
||||
|
||||
// Show the info of all the option blocks
|
||||
func rcOptionsInfo(ctx context.Context, in Params) (out Params, err error) {
|
||||
out = make(Params)
|
||||
for _, opt := range fs.OptionsRegistry {
|
||||
out[opt.Name] = opt.Options
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
Add(Call{
|
||||
Path: "options/local",
|
||||
|
||||
Reference in New Issue
Block a user