Allow immediately executing RPC with no input
Story: https://tree.taiga.io/project/jktjkt-netconf-cli/us/189
Change-Id: I876437b798e995c4484e97b409117a2bb207e864
diff --git a/src/path_parser.hpp b/src/path_parser.hpp
index 58d174e..c3df931 100644
--- a/src/path_parser.hpp
+++ b/src/path_parser.hpp
@@ -428,12 +428,28 @@
} const writableLeafPath;
-struct RpcActionPath : x3::parser<RpcActionPath> {
+enum class AllowInput {
+ Yes,
+ No
+};
+
+template <AllowInput ALLOW_INPUT>
+struct RpcActionPath : x3::parser<RpcActionPath<ALLOW_INPUT>> {
using attribute_type = dataPath_;
template <typename It, typename Ctx, typename RCtx, typename Attr>
static bool parse(It& begin, It end, Ctx const& ctx, RCtx& rctx, Attr& attr)
{
- bool res = dataPath.parse(begin, end, ctx, rctx, attr);
+ auto grammar = PathParser<PathParserMode::DataPath, CompletionMode::Data>{[] (const Schema& schema, const std::string& path) {
+ if constexpr (ALLOW_INPUT == AllowInput::No) {
+ auto nodeType = schema.nodeType(path);
+ if (nodeType == yang::NodeTypes::Rpc || nodeType == yang::NodeTypes::Action) {
+ return !schema.hasInputNodes(path);
+ }
+ }
+
+ return true;
+ }};
+ bool res = grammar.parse(begin, end, ctx, rctx, attr);
if (!res) {
return false;
}
@@ -449,8 +465,6 @@
}
};
-auto const rpcActionPath = as<dataPath_>[RpcActionPath()];
-
auto const noRpcOrAction = [](const Schema& schema, const std::string& path) {
auto nodeType = schema.nodeType(path);
return nodeType != yang::NodeTypes::Rpc && nodeType != yang::NodeTypes::Action;