yanglint REFACTOR print features in cmd_feature
diff --git a/tools/lint/cmd_feature.c b/tools/lint/cmd_feature.c
index a2ca07e..f3d784f 100644
--- a/tools/lint/cmd_feature.c
+++ b/tools/lint/cmd_feature.c
@@ -119,9 +119,6 @@
         goto cleanup;
     }
 
-    /* always erase the set, so the previous module's features don't carry over to the next module's features */
-    ly_set_erase(&set, NULL);
-
     mod = ly_ctx_get_module_latest(*ctx, posv);
     if (!mod) {
         YLMSG_E("Module \"%s\" not found.\n", posv);
@@ -144,7 +141,9 @@
         goto cleanup;
     }
 
-    print_features(yo->out, mod, &set);
+    if (yo->interactive) {
+        print_features(yo->out, mod, &set);
+    }
 
 cleanup:
     ly_set_erase(&set, NULL);
diff --git a/tools/lint/main_ni.c b/tools/lint/main_ni.c
index f35eb1b..63e05ae 100644
--- a/tools/lint/main_ni.c
+++ b/tools/lint/main_ni.c
@@ -769,17 +769,13 @@
     } else {
         if (yo.feature_param_format) {
             for (u = 0; u < yo.schema_modules.count; u++) {
-                if (collect_features(yo.schema_modules.objs[u], &set)) {
-                    YLMSG_E("Unable to read features from a module.\n");
+                if ((ret = cmd_feature_exec(&ctx, &yo, ((struct lys_module *)yo.schema_modules.objs[u])->name))) {
                     goto cleanup;
                 }
-                if (generate_features_output(yo.schema_modules.objs[u], &set, &features_output)) {
-                    YLMSG_E("Unable to generate feature command output.\n");
-                    goto cleanup;
-                }
-                ly_set_erase(&set, NULL);
             }
-            ly_print(yo.out, "%s\n", features_output);
+            if ((ret = cmd_feature_fin(ctx, &yo))) {
+                goto cleanup;
+            }
         } else if (yo.schema_out_format) {
             if (yo.schema_node) {
                 ret = lys_print_node(yo.out, yo.schema_node, yo.schema_out_format, yo.line_length, yo.schema_print_options);