yanglint UPDATE support for submodule print
... in non-interactive version.
Refs #1703
diff --git a/tools/lint/main_ni.c b/tools/lint/main_ni.c
index 80a13ed..f63e97a 100644
--- a/tools/lint/main_ni.c
+++ b/tools/lint/main_ni.c
@@ -63,6 +63,7 @@
/* specification of printing schema node subtree, option --schema-node */
const char *schema_node_path;
const struct lysc_node *schema_node;
+ const char *submodule;
/* value of --format in case of schema format */
LYS_OUTFORMAT schema_out_format;
@@ -168,6 +169,9 @@
" Supplement to the --schema-node option to print information\n"
" only about a single node specified as PATH argument.\n\n");
+ printf(" -s SUBMODULE, --submodule=SUBMODULE\n"
+ " Print the specific submodule instead of the main module.\n\n");
+
printf(" -n, --not-strict\n"
" Do not require strict data parsing (silently skip unknown data),\n"
" has no effect for schemas.\n\n");
@@ -367,6 +371,7 @@
{"makeimplemented", no_argument, NULL, 'i'},
{"schema-node", required_argument, NULL, 'P'},
{"single-node", no_argument, NULL, 'q'},
+ {"submodule", required_argument, NULL, 's'},
{"not-strict", no_argument, NULL, 'n'},
{"present", no_argument, NULL, 'e'},
{"type", required_argument, NULL, 't'},
@@ -390,9 +395,9 @@
c->line_length = 0;
#ifndef NDEBUG
- while ((opt = getopt_long(argc, argv, "hvVf:p:DF:iP:qnet:d:lL:o:Omy", options, &opt_index)) != -1) {
+ while ((opt = getopt_long(argc, argv, "hvVf:p:DF:iP:qs:net:d:lL:o:Omy", options, &opt_index)) != -1) {
#else
- while ((opt = getopt_long(argc, argv, "hvVf:p:DF:iP:qnet:d:lL:o:OmyG:", options, &opt_index)) != -1) {
+ while ((opt = getopt_long(argc, argv, "hvVf:p:DF:iP:qs:net:d:lL:o:OmyG:", options, &opt_index)) != -1) {
#endif
switch (opt) {
case 'h': /* --help */
@@ -494,6 +499,10 @@
c->schema_print_options |= LYS_PRINT_NO_SUBSTMT;
break;
+ case 's': /* --submodule */
+ c->submodule = optarg;
+ break;
+
case 'n': /* --not-strict */
c->data_parse_options &= ~LYD_PARSE_STRICT;
break;
@@ -730,6 +739,18 @@
YLMSG_E("Unable to print schema node %s.\n", c.schema_node_path);
goto cleanup;
}
+ } else if (c.submodule) {
+ const struct lysp_submodule *submod = ly_ctx_get_submodule_latest(c.ctx, c.submodule);
+ if (!submod) {
+ YLMSG_E("Unable to find submodule %s.\n", c.submodule);
+ goto cleanup;
+ }
+
+ ret = lys_print_submodule(c.out, submod, c.schema_out_format, c.line_length, c.schema_print_options);
+ if (ret) {
+ YLMSG_E("Unable to print submodule %s.\n", submod->name);
+ goto cleanup;
+ }
} else {
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,