yanglint FEATURE error on non-applied features
diff --git a/tools/lint/common.c b/tools/lint/common.c
index 5c5894e..650aa78 100644
--- a/tools/lint/common.c
+++ b/tools/lint/common.c
@@ -114,6 +114,7 @@
if (!strcmp(module, sf->mod_name)) {
/* matched module - explicitly set features */
*features = (const char **)sf->features;
+ sf->applied = 1;
return;
}
}
diff --git a/tools/lint/common.h b/tools/lint/common.h
index 72ce1bd..ae37df2 100644
--- a/tools/lint/common.h
+++ b/tools/lint/common.h
@@ -50,6 +50,7 @@
struct schema_features {
char *mod_name;
char **features;
+ ly_bool applied;
};
/**
diff --git a/tools/lint/main_ni.c b/tools/lint/main_ni.c
index ace7ea0..2e76c6d 100644
--- a/tools/lint/main_ni.c
+++ b/tools/lint/main_ni.c
@@ -271,10 +271,25 @@
}
}
+static struct schema_features *
+get_features_not_applied(const struct ly_set *fset)
+{
+ for (uint32_t u = 0; u < fset->count; ++u) {
+ struct schema_features *sf = fset->objs[u];
+ if (!sf->applied) {
+ return sf;
+ }
+ }
+
+ return NULL;
+}
+
static int
fill_context_inputs(int argc, char *argv[], struct context *c)
{
struct ly_in *in;
+ struct schema_features *sf;
+ const char *all_features[] = {"*", NULL};
/* process the operational content if any */
if (c->data_operational.path) {
@@ -347,6 +362,19 @@
}
}
+ /* check that all secified features were applied */
+ sf = get_features_not_applied(&c->schema_features);
+ if (sf) {
+ if (ly_ctx_get_module_implemented(c->ctx, sf->mod_name)) {
+ YLMSG_E("Specified features not applied, module \"%s\" must be parsed explicitly.\n", sf->mod_name);
+ } else if (ly_ctx_get_module_latest(c->ctx, sf->mod_name)) {
+ YLMSG_E("Specified features not applied, module \"%s\" not implemented.\n", sf->mod_name);
+ } else {
+ YLMSG_E("Specified features not applied, module \"%s\" not found.\n", sf->mod_name);
+ }
+ goto error;
+ }
+
return 0;
error: