Skip to content

Commit f8e9aa4

Browse files
committed
yanglint CHANGE allow working with lyb data files
1 parent a7a9a97 commit f8e9aa4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tools/lint/commands.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ cmd_print_help(void)
7373
void
7474
cmd_data_help(void)
7575
{
76-
printf("data [-(-s)trict] [-t TYPE] [-d DEFAULTS] [-o <output-file>] [-f (xml | json)] [-r <running-file-name>]\n");
76+
printf("data [-(-s)trict] [-t TYPE] [-d DEFAULTS] [-o <output-file>] [-f (xml | json | lyb)] [-r <running-file-name>]\n");
7777
printf(" <data-file-name> [<RPC/action-data-file-name> | <yang-data name>]\n\n");
7878
printf("Accepted TYPEs:\n");
7979
printf("\tauto - resolve data type (one of the following) automatically (as pyang does),\n");
@@ -436,6 +436,8 @@ detect_data_format(char *filepath)
436436
return LYD_XML;
437437
} else if (len >= 6 && !strcmp(&filepath[len - 5], ".json")) {
438438
return LYD_JSON;
439+
} else if (len >= 5 && !strcmp(&filepath[len - 4], ".lyb")) {
440+
return LYD_LYB;
439441
} else {
440442
return LYD_UNKNOWN;
441443
}
@@ -454,7 +456,7 @@ parse_data(char *filepath, int *options, struct lyd_node *val_tree, const char *
454456
/* detect input format according to file suffix */
455457
informat = detect_data_format(filepath);
456458
if (informat == LYD_UNKNOWN) {
457-
fprintf(stderr, "Unable to resolve format of the input file, please add \".xml\" or \".json\" suffix.\n");
459+
fprintf(stderr, "Unable to resolve format of the input file, please add \".xml\", \".json\", or \".lyb\" suffix.\n");
458460
return EXIT_FAILURE;
459461
}
460462

@@ -701,6 +703,8 @@ cmd_data(const char *arg)
701703
outformat = LYD_XML;
702704
} else if (!strcmp(optarg, "json")) {
703705
outformat = LYD_JSON;
706+
} else if (!strcmp(optarg, "lyb")) {
707+
outformat = LYD_LYB;
704708
} else {
705709
fprintf(stderr, "Unknown output format \"%s\".\n", optarg);
706710
goto cleanup;

0 commit comments

Comments
 (0)