yanglint REFACTOR parsing of --in-format argument
diff --git a/tools/lint/cmd_data.c b/tools/lint/cmd_data.c
index a7ee036..39e4d8c 100644
--- a/tools/lint/cmd_data.c
+++ b/tools/lint/cmd_data.c
@@ -194,13 +194,7 @@
             }
             break;
         case 'F': /* --in-format */
-            if (!strcasecmp(optarg, "xml")) {
-                yo->data_in_format = LYD_XML;
-            } else if (!strcasecmp(optarg, "json")) {
-                yo->data_in_format = LYD_JSON;
-            } else if (!strcasecmp(optarg, "lyb")) {
-                yo->data_in_format = LYD_LYB;
-            } else {
+            if (yo_opt_update_data_in_format(optarg, yo)) {
                 YLMSG_E("Unknown input format %s\n", optarg);
                 cmd_data_help_in_format();
                 return 1;
diff --git a/tools/lint/main_ni.c b/tools/lint/main_ni.c
index d7ec053..3057366 100644
--- a/tools/lint/main_ni.c
+++ b/tools/lint/main_ni.c
@@ -534,13 +534,7 @@
             break;
 
         case 'I': /* --in-format */
-            if (!strcasecmp(optarg, "xml")) {
-                yo->data_in_format = LYD_XML;
-            } else if (!strcasecmp(optarg, "json")) {
-                yo->data_in_format = LYD_JSON;
-            } else if (!strcasecmp(optarg, "lyb")) {
-                yo->data_in_format = LYD_LYB;
-            } else {
+            if (yo_opt_update_data_in_format(optarg, yo)) {
                 YLMSG_E("Unknown input format %s\n", optarg);
                 help(1);
                 return -1;
diff --git a/tools/lint/yl_opt.c b/tools/lint/yl_opt.c
index d9bcbca..71492b2 100644
--- a/tools/lint/yl_opt.c
+++ b/tools/lint/yl_opt.c
@@ -218,6 +218,22 @@
     return 0;
 }
 
+int
+yo_opt_update_data_in_format(const char *arg, struct yl_opt *yo)
+{
+    if (!strcasecmp(arg, "xml")) {
+        yo->data_in_format = LYD_XML;
+    } else if (!strcasecmp(arg, "json")) {
+        yo->data_in_format = LYD_JSON;
+    } else if (!strcasecmp(arg, "lyb")) {
+        yo->data_in_format = LYD_LYB;
+    } else {
+        return 1;
+    }
+
+    return 0;
+}
+
 void
 free_cmdline(char *argv[])
 {
diff --git a/tools/lint/yl_opt.h b/tools/lint/yl_opt.h
index 82a4172..a1569dd 100644
--- a/tools/lint/yl_opt.h
+++ b/tools/lint/yl_opt.h
@@ -197,6 +197,15 @@
 int yo_opt_update_data_default(const char *arg, struct yl_opt *yo);
 
 /**
+ * @brief Update @p yo according to the @p arg of the data --in-format parameter.
+ *
+ * @param[in] arg Format parameter argument (for example xml, json, ...).
+ * @param[out] yo yanglint options used to update.
+ * @return 0 on success.
+ */
+int yo_opt_update_data_in_format(const char *arg, struct yl_opt *yo);
+
+/**
  * @brief Helper function to prepare argc, argv pair from a command line string.
  *
  * @param[in] cmdline Complete command line string.