schema printers FEATURE print compiled schema as YANG (LYS_OUT_YANG_COMPILED)
diff --git a/tools/lint/commands.c b/tools/lint/commands.c
index 0e7913a..bb6bf1b 100644
--- a/tools/lint/commands.c
+++ b/tools/lint/commands.c
@@ -346,13 +346,14 @@
int
cmd_print(const char *arg)
{
- int c, argc, option_index, ret = 1, tree_ll = 0, tree_opts = 0;
+ int c, argc, option_index, ret = 1, tree_ll = 0, tree_opts = 0, compiled = 0;
char **argv = NULL, *ptr, *model_name, *revision;
const char *out_path = NULL;
const struct lys_module *module;
LYS_OUTFORMAT format = LYS_OUT_TREE;
FILE *output = stdout;
static struct option long_options[] = {
+ {"compiled", no_argument, 0, 'c'},
{"help", no_argument, 0, 'h'},
{"format", required_argument, 0, 'f'},
{"output", required_argument, 0, 'o'},
@@ -386,12 +387,15 @@
optind = 0;
while (1) {
option_index = 0;
- c = getopt_long(argc, argv, "hf:go:guP:L:", long_options, &option_index);
+ c = getopt_long(argc, argv, "chf:go:guP:L:", long_options, &option_index);
if (c == -1) {
break;
}
switch (c) {
+ case 'c':
+ compiled = 1;
+ break;
case 'h':
cmd_print_help();
ret = 0;
@@ -453,6 +457,11 @@
goto cleanup;
}
+ /* compiled format */
+ if (compiled) {
+ format++;
+ }
+
/* tree fromat with or without gropings */
if ((tree_opts || tree_ll) && format != LYS_OUT_TREE) {
fprintf(stderr, "--tree options take effect only in case of the tree output format.\n");
diff --git a/tools/lint/main_ni.c b/tools/lint/main_ni.c
index 892d242..220ef33 100644
--- a/tools/lint/main_ni.c
+++ b/tools/lint/main_ni.c
@@ -254,7 +254,7 @@
main_ni(int argc, char* argv[])
{
int ret = EXIT_FAILURE;
- int opt, opt_index = 0, i, featsize = 0;
+ int opt, opt_index = 0, i, featsize = 0, compiled = 0;
struct option options[] = {
#if 0
{"auto", no_argument, NULL, 'a'},
@@ -269,6 +269,7 @@
{"tree-path", required_argument, NULL, 'P'},
{"tree-line-length", required_argument, NULL, 'L'},
#endif
+ {"compiled", no_argument, NULL, 'c'},
{"help", no_argument, NULL, 'h'},
#if 0
{"tree-help", no_argument, NULL, 'H'},
@@ -330,9 +331,9 @@
opterr = 0;
#ifndef NDEBUG
- while ((opt = getopt_long(argc, argv, "ad:f:F:gunP:L:hHiDlmo:p:r:O:st:vVG:y:", options, &opt_index)) != -1)
+ while ((opt = getopt_long(argc, argv, "acd:f:F:gunP:L:hHiDlmo:p:r:O:st:vVG:y:", options, &opt_index)) != -1)
#else
- while ((opt = getopt_long(argc, argv, "ad:f:F:gunP:L:hHiDlmo:p:r:O:st:vVy:", options, &opt_index)) != -1)
+ while ((opt = getopt_long(argc, argv, "acd:f:F:gunP:L:hHiDlmo:p:r:O:st:vVy:", options, &opt_index)) != -1)
#endif
{
switch (opt) {
@@ -356,6 +357,9 @@
}
break;
#endif
+ case 'c':
+ compiled = 1;
+ break;
case 'f':
if (!strcasecmp(optarg, "yang")) {
outformat_s = LYS_OUT_YANG;
@@ -603,6 +607,13 @@
fprintf(stderr, "yanglint error: missing <file> to process\n");
goto cleanup;
}
+ if (compiled) {
+ if (!outformat_s) {
+ fprintf(stderr, "yanglint warning: --compiled option takes effect only in case of printing schemas.\n");
+ } else {
+ outformat_s++;
+ }
+ }
if (outformat_s && outformat_s != LYS_OUT_TREE && (optind + 1) < argc) {
/* we have multiple schemas to be printed as YIN or YANG */
fprintf(stderr, "yanglint error: too many schemas to convert and store.\n");