From 636c301bc540714236ec0f6f996a6bd36dc29c88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9r=C3=A9my=20Hutin?= Date: Thu, 17 Aug 2023 12:18:51 +0200 Subject: [PATCH] refacto getPNode (nodeToString) for consistency --- CLI/ast.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/CLI/ast.go b/CLI/ast.go index 362b14ca9..c362c8535 100644 --- a/CLI/ast.go +++ b/CLI/ast.go @@ -369,33 +369,25 @@ func (n *getObjectNode) execute() (interface{}, error) { } type getPNode struct { - path node + path node filter node } func (n *getPNode) execute() (interface{}, error) { - val, err := n.path.execute() + path, err := nodeToString(n.path, "path") if err != nil { return nil, err } - path, ok := val.(string) - if !ok { - return nil, fmt.Errorf("Object path should be a string") - } - val ,err = n.filter.execute() + filter, err := nodeToString(n.filter, "filter") if err != nil { return nil, err } - filter, ok := val.(string) - if !ok { - return nil, fmt.Errorf("Object filter should be a string") - } - obj,err := cmd.GetDevicesInfo(path,filter) + obj, err := cmd.GetDevicesInfo(path, filter) if err != nil { return nil, err } cmd.DisplayObject(obj) - return obj,nil + return obj, nil } type selectObjectNode struct {