mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
rc: allow JSON parameters to simplify command line usage
If the parameter being passed is an object then it can be passed as a
JSON string rather than using the `--json` flag which simplifies the
command line.
rclone rc operations/list fs=/tmp remote=test opt='{"showHash": true}'
Rather than
rclone rc operations/list --json '{"fs": "/tmp", "remote": "test", "opt": {"showHash": true}}'
This commit is contained in:
@@ -304,6 +304,20 @@ func TestParamsGetStruct(t *testing.T) {
|
||||
assert.Equal(t, true, IsErrParamInvalid(e3), e3.Error())
|
||||
}
|
||||
|
||||
func TestParamsGetStructString(t *testing.T) {
|
||||
in := Params{
|
||||
"struct": `{"String": "one", "Float": 4.2}`,
|
||||
}
|
||||
var out struct {
|
||||
String string
|
||||
Float float64
|
||||
}
|
||||
e1 := in.GetStruct("struct", &out)
|
||||
assert.NoError(t, e1)
|
||||
assert.Equal(t, "one", out.String)
|
||||
assert.Equal(t, 4.2, out.Float)
|
||||
}
|
||||
|
||||
func TestParamsGetStructMissingOK(t *testing.T) {
|
||||
in := Params{
|
||||
"struct": Params{
|
||||
|
||||
Reference in New Issue
Block a user