diff --git a/main.go b/main.go index 1158243..ff570fd 100644 --- a/main.go +++ b/main.go @@ -231,13 +231,13 @@ func usage() { func printResponse(out io.Writer, res response) { if res.Error.Code != 0 { - fmt.Fprintf(out, "Error %d: %s", res.Error.Code, res.Error.Message) + fmt.Fprintf(out, "Error %d: %s\n", res.Error.Code, res.Error.Message) } else if res.Result != nil { switch result := res.Result.(type) { case []interface{}: for _, res := range result { switch res := res.(type) { - case string, int, json.Number: + case string, float64, int, json.Number: fmt.Fprintln(out, res) default: bs, _ := json.MarshalIndent(res, "", " ") diff --git a/parse.go b/parse.go index 795edd7..2f6a9f8 100644 --- a/parse.go +++ b/parse.go @@ -88,6 +88,10 @@ func parseCommand(line string) (command, error) { parts := strings.Split(param, ",") obj := map[string]string{} for _, part := range parts { + if !strings.Contains(part, "=") { + obj[part] = "" + continue + } kv := strings.SplitN(part, "=", 2) obj[kv[0]] = kv[1] } diff --git a/parse_test.go b/parse_test.go index 2871159..5731216 100644 --- a/parse_test.go +++ b/parse_test.go @@ -51,6 +51,13 @@ func TestParseCommand(t *testing.T) { Params: []interface{}{"subscriber", "1234", map[string]interface{}{"foo": "bar 1", "baz 2": "quux 2"}}, }, }, + { + `object update subscriber 1234 foo=,bar`, + command{ + Method: "object.update", + Params: []interface{}{"subscriber", "1234", map[string]string{"foo": "", "bar": ""}}, + }, + }, } for _, tc := range testcases {