Disable rpc node completion for get
Issue: https://tree.taiga.io/project/jktjkt-netconf-cli/issue/192
Change-Id: Ib48cf042935bae974a846f0a7c7af3cc61f3e53e
diff --git a/src/ast_handlers.hpp b/src/ast_handlers.hpp
index e583207..c4658e4 100644
--- a/src/ast_handlers.hpp
+++ b/src/ast_handlers.hpp
@@ -236,6 +236,8 @@
struct cdPath_class;
+struct getPath_class;
+
struct set_class {
template <typename Iterator, typename Exception, typename Context>
x3::error_handler_result on_error(Iterator&, Iterator const&, Exception const& x, Context const& context)
diff --git a/src/grammars.hpp b/src/grammars.hpp
index 86dda33..161a515 100644
--- a/src/grammars.hpp
+++ b/src/grammars.hpp
@@ -64,7 +64,7 @@
delete_::name >> space_separator > (presenceContainerPath | listInstancePath | leafListElementPath | writableLeafPath);
auto const get_def =
- get_::name >> -(space_separator >> ((dataPathListEnd | dataPath) | (module >> "*")));
+ get_::name >> -(space_separator >> getPath);
auto const set_def =
set_::name >> space_separator > writableLeafPath > space_separator > leaf_data;
diff --git a/src/path_parser.hpp b/src/path_parser.hpp
index 65e5140..b3e9418 100644
--- a/src/path_parser.hpp
+++ b/src/path_parser.hpp
@@ -15,6 +15,7 @@
namespace x3 = boost::spirit::x3;
x3::rule<cdPath_class, dataPath_> const cdPath = "cdPath";
+x3::rule<getPath_class, decltype(get_::m_path)> const getPath = "getPath";
x3::rule<rpcPath_class, dataPath_> const rpcPath = "rpcPath";
x3::rule<presenceContainerPath_class, dataPath_> const presenceContainerPath = "presenceContainerPath";
x3::rule<listInstancePath_class, dataPath_> const listInstancePath = "listInstancePath";
@@ -454,6 +455,11 @@
return nodeType != yang::NodeTypes::Rpc && nodeType != yang::NodeTypes::Action;
};
+auto const getPath_def =
+ PathParser<PathParserMode::DataPathListEnd, CompletionMode::Data>{noRpcOrAction} |
+ PathParser<PathParserMode::DataPath, CompletionMode::Data>{noRpcOrAction} |
+ (module >> "*");
+
auto const cdPath_def =
PathParser<PathParserMode::DataPath, CompletionMode::Data>{noRpcOrAction};
@@ -480,6 +486,7 @@
BOOST_SPIRIT_DEFINE(key_identifier)
BOOST_SPIRIT_DEFINE(listSuffix)
BOOST_SPIRIT_DEFINE(cdPath)
+BOOST_SPIRIT_DEFINE(getPath)
BOOST_SPIRIT_DEFINE(presenceContainerPath)
BOOST_SPIRIT_DEFINE(listInstancePath)
BOOST_SPIRIT_DEFINE(leafListElementPath)
diff --git a/tests/path_completion.cpp b/tests/path_completion.cpp
index 0b0d3f8..0585be0 100644
--- a/tests/path_completion.cpp
+++ b/tests/path_completion.cpp
@@ -359,5 +359,12 @@
expectedContextLength = 0;
}
+ SECTION("rpc nodes not completed for the get command")
+ {
+ input = "get ";
+ expectedCompletions = {"example:addresses", "example:ano/", "example:anoda/", "example:bota/", "example:leafInt ", "example:list", "example:ovoce", "example:ovocezelenina", "example:readonly ", "example:twoKeyList", "second:amelie/"};
+ expectedContextLength = 0;
+ }
+
REQUIRE(parser.completeCommand(input, errorStream) == (Completions{expectedCompletions, expectedContextLength}));
}