yanglint REFACTOR reflect changes in libyang 2.0 in yanglint
diff --git a/tools/lint/completion.c b/tools/lint/completion.c
index 2d66926..4db17a0 100644
--- a/tools/lint/completion.c
+++ b/tools/lint/completion.c
@@ -22,9 +22,11 @@
 
 #include "libyang.h"
 
-#include "commands.h"
+#include "cmd.h"
+#include "common.h"
 #include "linenoise/linenoise.h"
 
+/* from the main.c */
 extern struct ly_ctx *ctx;
 
 static void
@@ -41,11 +43,11 @@
             ++(*match_count);
             p = realloc(*matches, *match_count * sizeof **matches);
             if (!p) {
-                fprintf(stderr, "Memory allocation failed (%s:%d, %s)", __FILE__, __LINE__, strerror(errno));
+                YLMSG_E("Memory allocation failed (%s:%d, %s)", __FILE__, __LINE__, strerror(errno));
                 return;
             }
             *matches = p;
-            (*matches)[*match_count-1] = strdup(commands[i].name);
+            (*matches)[*match_count - 1] = strdup(commands[i].name);
         }
     }
 }
@@ -92,11 +94,11 @@
             ++(*match_count);
             p = realloc(*matches, *match_count * sizeof **matches);
             if (!p) {
-                fprintf(stderr, "Memory allocation failed (%s:%d, %s)", __FILE__, __LINE__, strerror(errno));
+                YLMSG_E("Memory allocation failed (%s:%d, %s)", __FILE__, __LINE__, strerror(errno));
                 return;
             }
             *matches = p;
-            (*matches)[*match_count-1] = strdup(module->name);
+            (*matches)[*match_count - 1] = strdup(module->name);
         }
 
         LY_ARRAY_FOR(module->parsed->includes, u) {
@@ -104,11 +106,11 @@
                 ++(*match_count);
                 p = realloc(*matches, *match_count * sizeof **matches);
                 if (!p) {
-                    fprintf(stderr, "Memory allocation failed (%s:%d, %s)", __FILE__, __LINE__, strerror(errno));
+                    YLMSG_E("Memory allocation failed (%s:%d, %s)", __FILE__, __LINE__, strerror(errno));
                     return;
                 }
                 *matches = p;
-                (*matches)[*match_count-1] = strdup(module->parsed->includes[u].submodule->name);
+                (*matches)[*match_count - 1] = strdup(module->parsed->includes[u].submodule->name);
             }
         }
     }
@@ -122,9 +124,9 @@
 
     if (!strncmp(buf, "add ", 4)) {
         linenoisePathCompletion(buf, hint, lc);
-    } else if ((!strncmp(buf, "searchpath ", 11) || !strncmp(buf, "data ", 5)
-            || !strncmp(buf, "config ", 7) || !strncmp(buf, "filter ", 7)
-            || !strncmp(buf, "xpath ", 6) || !strncmp(buf, "clear ", 6)) && !last_is_opt(hint)) {
+    } else if ((!strncmp(buf, "searchpath ", 11) || !strncmp(buf, "data ", 5) ||
+            !strncmp(buf, "config ", 7) || !strncmp(buf, "filter ", 7) ||
+            !strncmp(buf, "xpath ", 6) || !strncmp(buf, "clear ", 6)) && !last_is_opt(hint)) {
         linenoisePathCompletion(buf, hint, lc);
     } else if ((!strncmp(buf, "print ", 6) || !strncmp(buf, "feature ", 8)) && !last_is_opt(hint)) {
         get_model_completion(hint, &matches, &match_count);