YANG schema: refactor schema search dirs support

I got very confused, because the code in netconf-cli calls these methods
"addFoo", whereas the libayng-cpp calls them "setFoo", even though all
of them simply extend the "foo" with the provided argument. So, let's
refactor these.

Start by making the interface a bit more type safe with
`std::filesystem::path`, and then change the interface of the `yang-cli`
program so that the `-s` option can be now specified several times.

Change-Id: Iad40696b0e133c60e0c0a1512da851650f6ac8a0
diff --git a/src/cli.cpp b/src/cli.cpp
index 9827fa3..6940205 100644
--- a/src/cli.cpp
+++ b/src/cli.cpp
@@ -40,12 +40,12 @@
   will be used to find a schema for that module.
 
 Usage:
-  yang-cli [--configonly] [--ignore-unknown-data] [-s <search_dir>] [-e enable_features]... [-i data_file]... <schema_file_or_module_name>...
+  yang-cli [--configonly] [--ignore-unknown-data] [-s <search_dir>]... [-e enable_features]... [-i data_file]... <schema_file_or_module_name>...
   yang-cli (-h | --help)
   yang-cli --version
 
 Options:
-  -s <search_dir>        Set search for schema lookup
+  -s <search_dir>        Search in these directories for YANG schema files. This option can be supplied more than once.
   -e <enable_features>   Feature to enable after modules are loaded. This option can be supplied more than once. Format: <module_name>:<feature>
   -i <data_file>         File to import data from
   --configonly           Disable editing of operational data
@@ -124,8 +124,8 @@
         writableOps = WritableOps::Yes;
         std::cout << "ops is writable" << std::endl;
     }
-    if (const auto& search_dir = args["-s"]) {
-        datastore->addSchemaDir(search_dir.asString());
+    for (const auto& dir : args["-s"].asStringList()) {
+        datastore->addSchemaDir(dir);
     }
     for (const auto& schemaFile : args["<schema_file_or_module_name>"].asStringList()) {
         if (std::filesystem::exists(schemaFile)) {
diff --git a/src/yang_access.cpp b/src/yang_access.cpp
index 96efdb8..4d7556d 100644
--- a/src/yang_access.cpp
+++ b/src/yang_access.cpp
@@ -273,14 +273,14 @@
     m_schema->loadModule(name);
 }
 
-void YangAccess::addSchemaFile(const std::string& path)
+void YangAccess::addSchemaFile(const std::filesystem::path& path)
 {
-    m_schema->addSchemaFile(path.c_str());
+    m_schema->addSchemaFile(path);
 }
 
-void YangAccess::addSchemaDir(const std::string& path)
+void YangAccess::addSchemaDir(const std::filesystem::path& path)
 {
-    m_schema->addSchemaDirectory(path.c_str());
+    m_schema->addSchemaDirectory(path);
 }
 
 void YangAccess::setEnabledFeatures(const std::string& module, const std::vector<std::string>& features)
diff --git a/src/yang_access.hpp b/src/yang_access.hpp
index aab5d81..17586b5 100644
--- a/src/yang_access.hpp
+++ b/src/yang_access.hpp
@@ -45,8 +45,8 @@
     [[nodiscard]] std::string dump(const DataFormat format) const override;
 
     void loadModule(const std::string& name);
-    void addSchemaFile(const std::string& path);
-    void addSchemaDir(const std::string& path);
+    void addSchemaFile(const std::filesystem::path& path);
+    void addSchemaDir(const std::filesystem::path& path);
     void addDataFile(const std::string& path, const StrictDataParsing strict);
 
 private:
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index 26ef38d..3c5456e 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -48,14 +48,14 @@
     m_context.parseModule(std::string{schema}, libyang::SchemaFormat::YANG);
 }
 
-void YangSchema::addSchemaDirectory(const char* directoryName)
+void YangSchema::addSchemaDirectory(const std::filesystem::path& directory)
 {
-    m_context.setSearchDir(directoryName);
+    m_context.setSearchDir(directory);
 }
 
-void YangSchema::addSchemaFile(const char* filename)
+void YangSchema::addSchemaFile(const std::filesystem::path& filename)
 {
-    m_context.parseModule(std::filesystem::path{filename}, libyang::SchemaFormat::YANG);
+    m_context.parseModule(filename, libyang::SchemaFormat::YANG);
 }
 
 bool YangSchema::isModule(const std::string& name) const
diff --git a/src/yang_schema.hpp b/src/yang_schema.hpp
index fe5cf1c..36766d6 100644
--- a/src/yang_schema.hpp
+++ b/src/yang_schema.hpp
@@ -8,6 +8,7 @@
 
 #pragma once
 
+#include <filesystem>
 #include <functional>
 #include <libyang-cpp/Context.hpp>
 #include <optional>
@@ -54,10 +55,10 @@
     void addSchemaString(const char* schema);
 
     /** @short Adds a new module from a file. */
-    void addSchemaFile(const char* filename);
+    void addSchemaFile(const std::filesystem::path& filename);
 
     /** @short Adds a new directory for schema lookup. */
-    void addSchemaDirectory(const char* directoryName);
+    void addSchemaDirectory(const std::filesystem::path& directory);
 
     /** @short Creates a new data node from a path (to be used with NETCONF edit-config) */
     [[nodiscard]] libyang::CreatedNodes dataNodeFromPath(const std::string& path, const std::optional<const std::string> value = std::nullopt) const;