Allow data path to end with a list for get and ls

Change-Id: I3facc8315fa6192da4318012a85121de37e7314b
diff --git a/src/interpreter.cpp b/src/interpreter.cpp
index 452bc74..80e6195 100644
--- a/src/interpreter.cpp
+++ b/src/interpreter.cpp
@@ -84,14 +84,39 @@
         return joinPaths(m_parser.currentNode(), pathToDataString(command.m_path));
 }
 
+struct pathToStringVisitor : boost::static_visitor<std::string> {
+    std::string operator()(const schemaPath_& path) const
+    {
+        return pathToSchemaString(path);
+    }
+    std::string operator()(const dataPath_& path) const
+    {
+        return pathToDataString(path);
+    }
+};
+
+struct getPathScopeVisitor : boost::static_visitor<Scope> {
+    template <typename T>
+    Scope operator()(const T& path) const
+    {
+        return path.m_scope;
+    }
+};
+
 std::string Interpreter::absolutePathFromCommand(const get_& get) const
 {
     if (!get.m_path) {
         return m_parser.currentNode();
-    } else if (get.m_path->m_scope == Scope::Absolute) {
-        return "/" + pathToDataString(*get.m_path);
+    }
+
+    const auto path = *get.m_path;
+    std::string pathString = boost::apply_visitor(pathToStringVisitor(), path);
+    auto pathScope{boost::apply_visitor(getPathScopeVisitor(), path)};
+
+    if (pathScope == Scope::Absolute) {
+        return "/" + pathString;
     } else {
-        return joinPaths(m_parser.currentNode(), pathToDataString(*get.m_path));
+        return joinPaths(m_parser.currentNode(), pathString);
     }
 }