This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newtmgr.git

commit 80e5c283e6b155177814d1e5040be7807c0d75aa
Author: Christopher Collins <ccoll...@apache.org>
AuthorDate: Wed Feb 19 16:05:56 2020 -0800

    res: Correctly parse payload params
    
    In `newtmgr <op> <resource>> k1=v1 k2=v2 ...`, the tool was discarding
    all the k=v pairs and encoding an empty map instead.
---
 newtmgr/cli/res.go | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/newtmgr/cli/res.go b/newtmgr/cli/res.go
index 51ff7c8..fc422f4 100644
--- a/newtmgr/cli/res.go
+++ b/newtmgr/cli/res.go
@@ -255,27 +255,28 @@ func parsePayload(args []string) ([]byte, error) {
        var val interface{}
        var err error
 
+       if len(args) == 0 {
+               return nil, nil
+       }
+
        if resJson {
-               if len(args) == 0 {
-                       return nil, nil
-               }
-               itf, err := parsePayloadJson(args[0])
+               val, err = parsePayloadJson(args[0])
                if err != nil {
                        return nil, err
                }
                // Check for zero payload.  Need to return nil explicitly; 
don't wrap
                // in interface{}.
-               if itf == nil {
+               if val == nil {
                        return nil, nil
                }
        } else {
-               itf, err := parsePayloadMap(args)
+               val, err = parsePayloadMap(args)
                if err != nil {
                        return nil, err
                }
                // Check for zero payload.  Need to return nil explicitly; 
don't wrap
                // in interface{}.
-               if itf == nil {
+               if val == nil {
                        return nil, nil
                }
        }

Reply via email to