yanglint BUGFIX enable all features if no specified
Clarify that this includes features in all
implemented modules, implement it that way.
Fixes #1719
diff --git a/tools/lint/cmd_add.c b/tools/lint/cmd_add.c
index c976624..ff025db 100644
--- a/tools/lint/cmd_add.c
+++ b/tools/lint/cmd_add.c
@@ -38,7 +38,7 @@
" even search in the module directory (all modules must be \n"
" explicitly specified).\n"
" -F FEATURES, --features=FEATURES\n"
- " Features to support, default all.\n"
+ " Features to support, default all in all implemented modules.\n"
" <modname>:[<feature>,]*\n"
" -i, --make-implemented\n"
" Make the imported modules \"referenced\" from any loaded\n"
@@ -111,6 +111,11 @@
goto cleanup;
}
+ if (!fset.count) {
+ /* no features, enable all of them */
+ options_ctx |= LY_CTX_ENABLE_IMP_FEATURES;
+ }
+
if (options_ctx) {
ly_ctx_set_options(*ctx, options_ctx);
}
diff --git a/tools/lint/cmd_load.c b/tools/lint/cmd_load.c
index 3da7553..a50e800 100644
--- a/tools/lint/cmd_load.c
+++ b/tools/lint/cmd_load.c
@@ -34,7 +34,7 @@
" them in searchpaths. if the <revision> of the module not\n"
" specified, the latest revision available is loaded.\n\n"
" -F FEATURES, --features=FEATURES\n"
- " Features to support, default all.\n"
+ " Features to support, default all in all implemented modules.\n"
" <modname>:[<feature>,]*\n"
" -i, --make-implemented\n"
" Make the imported modules \"referenced\" from any loaded\n"
@@ -94,6 +94,11 @@
goto cleanup;
}
+ if (!fset.count) {
+ /* no features, enable all of them */
+ options_ctx |= LY_CTX_ENABLE_IMP_FEATURES;
+ }
+
if (options_ctx) {
ly_ctx_set_options(*ctx, options_ctx);
}
diff --git a/tools/lint/main_ni.c b/tools/lint/main_ni.c
index 4ded136..1097301 100644
--- a/tools/lint/main_ni.c
+++ b/tools/lint/main_ni.c
@@ -152,7 +152,7 @@
" explicitly specified).\n\n");
printf(" -F FEATURES, --features=FEATURES\n"
- " Features to support, default all.\n"
+ " Features to support, default all in all implemented modules.\n"
" <modname>:[<feature>,]*\n\n");
printf(" -i, --make-implemented\n"
@@ -294,6 +294,7 @@
uint8_t path_unset = 1; /* flag to unset the path from the searchpaths list (if not already present) */
char *dir, *module;
const char **features = NULL;
+ uint16_t ctx_opts = 0;
struct lys_module *mod;
if (parse_schema_path(argv[optind + i], &dir, &module)) {
@@ -308,12 +309,20 @@
/* get features list for this module */
get_features(&c->schema_features, module, &features);
+ /* set imp feature flag if all should be enabled */
+ if (!c->schema_features.count) {
+ ctx_opts = LY_CTX_ENABLE_IMP_FEATURES;
+ ly_ctx_set_options(c->ctx, ctx_opts);
+ }
+
/* temporary cleanup */
free(dir);
free(module);
+ /* parse module */
ret = lys_parse(c->ctx, in, format_schema, features, &mod);
ly_ctx_unset_searchdir_last(c->ctx, path_unset);
+ ly_ctx_unset_options(c->ctx, ctx_opts);
ly_in_free(in, 1);
in = NULL;
if (ret) {