3
0

When setting settings value, fallback to quoted string in case of json syntax error

This commit is contained in:
Denis Arh 2020-01-18 06:56:53 +01:00
parent eabd98dce0
commit 7ae7b6f445

View File

@ -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)
}