Fix Parser storing context path wrongly
Parser was storing its context path as a relative path and manually
prepending a slash to it, when it was retrieved. Parser now correctly
stores it as absolute path and lets the convertor function add the
slash.
Issue: https://tree.taiga.io/project/jktjkt-netconf-cli/issue/145
Change-Id: If38c009a05a8ecbc2be00d646172e0ae97de748b
diff --git a/src/interpreter.cpp b/src/interpreter.cpp
index 3630c25..61604bb 100644
--- a/src/interpreter.cpp
+++ b/src/interpreter.cpp
@@ -109,7 +109,7 @@
std::string Interpreter::absolutePathFromCommand(const T& command) const
{
if (command.m_path.m_scope == Scope::Absolute)
- return "/" + pathToDataString(command.m_path);
+ return pathToDataString(command.m_path);
else
return joinPaths(m_parser.currentNode(), pathToDataString(command.m_path));
}
@@ -143,14 +143,13 @@
const auto path = *get.m_path;
if (path.type() == typeid(module_)) {
return "/"s + boost::get<module_>(path).m_name + ":*";
-
} else {
auto actualPath = boost::get<boost::variant<dataPath_, schemaPath_>>(path);
std::string pathString = boost::apply_visitor(pathToStringVisitor(), actualPath);
auto pathScope{boost::apply_visitor(getPathScopeVisitor(), actualPath)};
if (pathScope == Scope::Absolute) {
- return "/" + pathString;
+ return pathString;
} else {
return joinPaths(m_parser.currentNode(), pathString);
}
diff --git a/src/parser.cpp b/src/parser.cpp
index 370ba1b..c7644e2 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -18,6 +18,7 @@
Parser::Parser(const std::shared_ptr<const Schema> schema)
: m_schema(schema)
{
+ m_curDir.m_scope = Scope::Absolute;
}
command_ Parser::parseCommand(const std::string& line, std::ostream& errorStream)
@@ -79,7 +80,7 @@
std::string Parser::currentNode() const
{
- return "/" + pathToDataString(m_curDir);
+ return pathToDataString(m_curDir);
}
struct getSchemaPathVisitor : boost::static_visitor<schemaPath_> {