yang-cli: automatically extend the on-disk search path

When asking for a file to load as a YANG module, automatically add its
enclosing directory to the list of search paths. That way, if a module
imports other modules from the same directory, no `-s` parameter will be
needed.

There should be no harm in adding the same path over and over again, so
there's no point in tracking what paths have been already enabled.

Change-Id: I336efb7b5e6f923e7d9f82741ee93a88bb32bdbe
diff --git a/src/cli.cpp b/src/cli.cpp
index 6940205..175a7ed 100644
--- a/src/cli.cpp
+++ b/src/cli.cpp
@@ -128,7 +128,11 @@
         datastore->addSchemaDir(dir);
     }
     for (const auto& schemaFile : args["<schema_file_or_module_name>"].asStringList()) {
-        if (std::filesystem::exists(schemaFile)) {
+        std::filesystem::path path{schemaFile};
+        if (std::filesystem::exists(path)) {
+            if (std::filesystem::is_regular_file(path)) {
+                datastore->addSchemaDir(path.parent_path());
+            }
             datastore->addSchemaFile(schemaFile);
         } else if (schemaFile.find('/') == std::string::npos) { // Module names cannot have a slash
             datastore->loadModule(schemaFile);