fs: Add string alternatives for setting options over the rc

Before this change options were read and set in native format. This
means for example nanoseconds for durations or an integer for
enumerated types, which isn't very convenient for humans.

This change enables these types to be set with a string with the
syntax as used in the command line instead, so `"10s"` rather than
`10000000000` or `"DEBUG"` rather than `8` for log level.
This commit is contained in:
Nick Craig-Wood
2020-12-11 17:48:09 +00:00
parent e32f08f37b
commit ae3963e4b4
17 changed files with 516 additions and 20 deletions

View File

@@ -203,8 +203,6 @@ Rather than
rclone rc operations/list --json '{"fs": "/tmp", "remote": "test", "opt": {"showHash": true}}'
```
## Special parameters
The rc interface supports some special parameters which apply to
@@ -294,6 +292,29 @@ $ rclone rc --json '{ "group": "job/1" }' core/stats
}
```
## Data types
When the API returns types, these will mostly be straight forward
integer, string or boolean types.
However some of the types returned by the [options/get](#options-get)
call and taken by the [options/set](#options-set) calls as well as the
`vfsOpt` and the `mountOpt` are as follows:
- `Duration` - these are returned as an integer duration in
nanoseconds. They may be set as an integer, or they may be set with
time string, eg "5s". See the [options section](/docs/#options) for
more info.
- `Size` - these are returned as an integer number of bytes. They may
be set as an integer or they may be set with a size suffix string,
eg "10M". See the [options section](/docs/#options) for more info.
- Enumerated type (such as `CutoffMode`, `DumpFlags`, `LogLevel`,
`VfsCacheMode` - these will be returned as an integer and may be set
as an integer but more conveniently they can be set as a string, eg
"HARD" for `CutoffMode` or `DEBUG` for `LogLevel`.
- `BandwidthSpec` - this will be set and returned as a string, eg
"1M".
## Supported commands
{{< rem autogenerated start "- run make rcdocs - don't edit here" >}}
### backend/command: Runs a backend command. {#backend-command}
@@ -1155,17 +1176,18 @@ changed like this.
For example:
This sets DEBUG level logs (-vv)
This sets DEBUG level logs (-vv) (these can be set by number or string)
rclone rc options/set --json '{"main": {"LogLevel": "DEBUG"}}'
rclone rc options/set --json '{"main": {"LogLevel": 8}}'
And this sets INFO level logs (-v)
rclone rc options/set --json '{"main": {"LogLevel": 7}}'
rclone rc options/set --json '{"main": {"LogLevel": "INFO"}}'
And this sets NOTICE level logs (normal without -v)
rclone rc options/set --json '{"main": {"LogLevel": 6}}'
rclone rc options/set --json '{"main": {"LogLevel": "NOTICE"}}'
### pluginsctl/addPlugin: Add a plugin using url {#pluginsctl-addPlugin}