Move ls logic to Interpreter

Change-Id: I9d1e04573be5d7701e4e66e53aefb9dc1a1fd8ab
diff --git a/src/interpreter.cpp b/src/interpreter.cpp
index 8f419c3..9912584 100644
--- a/src/interpreter.cpp
+++ b/src/interpreter.cpp
@@ -76,7 +76,26 @@
             recursion = Recursion::Recursive;
     }
 
-    for (const auto& it : m_parser.availableNodes(ls.m_path, recursion))
+    std::set<std::string> toPrint;
+
+    auto pathArg = dataPathToSchemaPath(m_parser.currentPath());
+    if (ls.m_path) {
+        if (ls.m_path->type() == typeid(module_)) {
+            toPrint = m_datastore.schema()->availableNodes(*ls.m_path, recursion);
+        } else {
+            auto schemaPath = anyPathToSchemaPath(*ls.m_path);
+            if (schemaPath.m_scope == Scope::Absolute) {
+                pathArg = schemaPath;
+            } else {
+                pathArg.m_nodes.insert(pathArg.m_nodes.end(), schemaPath.m_nodes.begin(), schemaPath.m_nodes.end());
+            }
+            toPrint = m_datastore.schema()->availableNodes(pathArg, recursion);
+        }
+    } else {
+        toPrint = m_datastore.schema()->availableNodes(pathArg, recursion);
+    }
+
+    for (const auto& it : toPrint)
         std::cout << it << std::endl;
 }