yanglint FEATURE printing modules for YANG Tree
For YANG Tree Diagrams printing it's more readable to print a blank
line between modules. Based on mbj4668/pyang#681
diff --git a/tools/lint/cmd_print.c b/tools/lint/cmd_print.c
index 7d68823..823ca7b 100644
--- a/tools/lint/cmd_print.c
+++ b/tools/lint/cmd_print.c
@@ -93,8 +93,9 @@
LY_ERR erc;
char *name, *revision;
ly_bool search_submodul;
+ const int stop = argc - optind;
- for (int i = 0; i < argc - optind; i++) {
+ for (int i = 0; i < stop; i++) {
name = argv[optind + i];
/* get revision */
revision = strchr(name, '@');
@@ -113,6 +114,10 @@
}
if (erc == LY_SUCCESS) {
+ /* for YANG Tree Diagrams printing it's more readable to print a blank line between modules. */
+ if ((format == LYS_OUT_TREE) && (i + 1 < stop)) {
+ ly_print(out, "\n");
+ }
continue;
} else if (erc == LY_ENOTFOUND) {
if (revision) {
diff --git a/tools/lint/main_ni.c b/tools/lint/main_ni.c
index 76b6fe0..13eb1cd 100644
--- a/tools/lint/main_ni.c
+++ b/tools/lint/main_ni.c
@@ -26,6 +26,7 @@
#include "libyang.h"
#include "common.h"
+#include "out.h"
#include "tools/config.h"
/**
@@ -733,6 +734,10 @@
for (uint32_t u = 0; u < c.schema_modules.count; ++u) {
ret = lys_print_module(c.out, (struct lys_module *)c.schema_modules.objs[u], c.schema_out_format,
c.line_length, c.schema_print_options);
+ /* for YANG Tree Diagrams printing it's more readable to print a blank line between modules. */
+ if ((c.schema_out_format == LYS_OUT_TREE) && (u + 1 < c.schema_modules.count)) {
+ ly_print(c.out, "\n");
+ }
if (ret) {
YLMSG_E("Unable to print module %s.\n", ((struct lys_module *)c.schema_modules.objs[u])->name);
goto cleanup;