Request YANG schemas via sysrepo
The std::function that is fed into YangSchema::registerModuleCallback
does not have the same signature that libyang requires, because we would
have to include libyang in the sysrepo_access header file. We don't want this
class to know about libyang, so instead, we use an intermediate function,
that has string arguments and a string return type. In YangSchema, this
function is wrapped with another function, that has the required signature.
Change-Id: Ibd2dcb89344cf1454ba0b3970cac0c8e88ffa20d
diff --git a/src/main.cpp b/src/main.cpp
index a30cec1..f263b42 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -19,7 +19,7 @@
R"(CLI interface to remote NETCONF hosts
Usage:
- netconf-cli <path-to-yang-schema>...
+ netconf-cli
netconf-cli (-h | --help)
netconf-cli --version
)";
@@ -34,16 +34,8 @@
true);
std::cout << "Welcome to netconf-cli" << std::endl;
- auto yangschema = std::make_shared<YangSchema>();
- Parser parser(yangschema);
-
SysrepoAccess datastore("netconf-cli");
-
- for (auto it : args.at("<path-to-yang-schema>").asStringList()) {
- auto dir = std::experimental::filesystem::absolute(it).remove_filename();
- yangschema->addSchemaDirectory(dir.c_str());
- yangschema->addSchemaFile(it.c_str());
- }
+ Parser parser(datastore.schema());
while (true) {
std::cout << parser.currentNode() << "> ";