From 7ae7b6f445cc358d7ad299d9526093453532408d Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Sat, 18 Jan 2020 06:56:53 +0100 Subject: [PATCH] When setting settings value, fallback to quoted string in case of json syntax error --- system/commands/settings.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/system/commands/settings.go b/system/commands/settings.go index 75ad80959..fed821933 100644 --- a/system/commands/settings.go +++ b/system/commands/settings.go @@ -79,7 +79,13 @@ func Settings(ctx context.Context, c *cli.Config) *cobra.Command { Name: args[0], } - if err := v.SetRawValue(value); err != nil { + err := v.SetRawValue(value) + if _, is := err.(*json.SyntaxError); is { + // Quote the raw value and re-parse + err = v.SetRawValue(`"` + value + `"`) + } + + if err != nil { cli.HandleError(err) }