yanglint CHANGE unify options for parsing data
Unify option names in interactive and non-interactive modes for parsing
data:
-t is now data tree type
-x is now (only in non-interactive mode) extra data tree for the
RPC/Notification/action
diff --git a/tools/lint/commands.c b/tools/lint/commands.c
index 361a32d..695af32 100644
--- a/tools/lint/commands.c
+++ b/tools/lint/commands.c
@@ -53,9 +53,9 @@
void
cmd_data_help(void)
{
- printf("data [-(-s)trict] [-x OPTION] [-d DEFAULTS] [-o <output-file>] [-f (xml | json)] [-t <additional-tree-file-name>]\n");
+ printf("data [-(-s)trict] [-t TYPE] [-d DEFAULTS] [-o <output-file>] [-f (xml | json)] [-x <additional-tree-file-name>]\n");
printf(" <data-file-name> [<JSON-rpc/action-schema-nodeid>]\n");
- printf("Accepted OPTIONs:\n");
+ printf("Accepted TYPEs:\n");
printf("\tauto - resolve data type (one of the following) automatically (as pyang does),\n");
printf("\t this option is applicable only in case of XML input data.\n");
printf("\tconfig - LYD_OPT_CONFIG\n");
@@ -70,8 +70,8 @@
printf("\tall-tagged - add missing default nodes and mark all the default nodes with the attribute.\n");
printf("\ttrim - remove all nodes with a default value\n");
printf("\timplicit-tagged - add missing nodes and mark them with the attribute\n\n");
- printf("Option -t:\n");
- printf("\tIf RPC/action/notification/RPC reply (for OPTIONs 'rpc', 'rpcreply', and 'notif') includes\n");
+ printf("Option -x:\n");
+ printf("\tIf RPC/action/notification/RPC reply (for TYPEs 'rpc', 'rpcreply', and 'notif') includes\n");
printf("\tan XPath expression (when/must) that needs access to the configuration data, you can provide\n");
printf("\tthem in a file, which will be parsed as 'config'.\n");
}
@@ -79,9 +79,9 @@
void
cmd_xpath_help(void)
{
- printf("xpath [-x OPTION] [-t <additional-tree-file-name>] -e <XPath-expression>\n"
+ printf("xpath [-t TYPE] [-x <additional-tree-file-name>] -e <XPath-expression>\n"
" <XML-data-file-name> [<JSON-rpc/action-schema-nodeid>]\n");
- printf("Accepted OPTIONs:\n");
+ printf("Accepted TYPEs:\n");
printf("\tauto - resolve data type (one of the following) automatically (as pyang does),\n");
printf("\t this option is applicable only in case of XML input data.\n");
printf("\tconfig - LYD_OPT_CONFIG\n");
@@ -91,8 +91,8 @@
printf("\trpc - LYD_OPT_RPC\n");
printf("\trpcreply - LYD_OPT_RPCREPLY (last parameter mandatory in this case)\n");
printf("\tnotif - LYD_OPT_NOTIF\n\n");
- printf("Option -t:\n");
- printf("\tIf RPC/action/notification/RPC reply (for OPTIONs 'rpc', 'rpcreply', and 'notif') includes\n");
+ printf("Option -x:\n");
+ printf("\tIf RPC/action/notification/RPC reply (for TYPEs 'rpc', 'rpcreply', and 'notif') includes\n");
printf("\tan XPath expression (when/must) that needs access to the configuration data, you can provide\n");
printf("\tthem in a file, which will be parsed as 'config'.\n");
}
@@ -495,10 +495,10 @@
{"defaults", required_argument, 0, 'd'},
{"help", no_argument, 0, 'h'},
{"format", required_argument, 0, 'f'},
- {"option", required_argument, 0, 'x'},
+ {"option", required_argument, 0, 't'},
{"output", required_argument, 0, 'o'},
{"strict", no_argument, 0, 's'},
- {"validation-tree", required_argument, 0, 't'},
+ {"validation-tree", required_argument, 0, 'x'},
{NULL, 0, 0, 0}
};
@@ -515,7 +515,7 @@
optind = 0;
while (1) {
option_index = 0;
- c = getopt_long(argc, argv, "d:hf:o:sx:t:", long_options, &option_index);
+ c = getopt_long(argc, argv, "d:hf:o:st:x:", long_options, &option_index);
if (c == -1) {
break;
}
@@ -557,7 +557,7 @@
options |= LYD_OPT_STRICT;
options |= LYD_OPT_OBSOLETE;
break;
- case 'x':
+ case 't':
if (!strcmp(optarg, "auto")) {
options = (options & ~LYD_OPT_TYPEMASK) | LYD_OPT_TYPEMASK;
} else if (!strcmp(optarg, "config")) {
@@ -580,7 +580,7 @@
goto cleanup;
}
break;
- case 't':
+ case 'x':
val_tree = lyd_parse_path(ctx, optarg, LYD_XML, LYD_OPT_CONFIG);
if (!val_tree) {
fprintf(stderr, "Failed to parse the additional data tree for validation.\n");
@@ -699,7 +699,7 @@
case 'e':
expr = optarg;
break;
- case 'x':
+ case 't':
if (!strcmp(optarg, "auto")) {
options = (options & ~LYD_OPT_TYPEMASK) | LYD_OPT_TYPEMASK;
} else if (!strcmp(optarg, "config")) {
@@ -722,7 +722,7 @@
goto cleanup;
}
break;
- case 't':
+ case 'x':
val_tree = lyd_parse_path(ctx, optarg, LYD_XML, LYD_OPT_CONFIG);
if (!val_tree) {
fprintf(stderr, "Failed to parse the additional data tree for validation.\n");
diff --git a/tools/lint/examples/README.md b/tools/lint/examples/README.md
index 2016d70..57525d9 100644
--- a/tools/lint/examples/README.md
+++ b/tools/lint/examples/README.md
@@ -145,10 +145,10 @@
Command and its output:
```
-> data -x config datastore.xml
+> data -t config datastore.xml
```
-We use option `-x` to specify type of the data in `datastore.xml`. By the
+We use option `-t` to specify type of the data in `datastore.xml`. By the
`config` value we declare that the input file contains all the configuration
data (with at least all the mandatory nodes as required by the loaded schemas),
but without the status data. More examples of different data types will follow.
@@ -158,13 +158,13 @@
Command and its output:
```
-> data -x config -s datastore.xml
+> data -t config -s datastore.xml
libyang[0]: Unknown element "interfaces". (path: /)
Failed to parse data.
```
Note that in case of working with complete datastore including the status data
-(no `-x` option is specified), `yanglint(1)` has to add status data from its
+(no `-t` option is specified), `yanglint(1)` has to add status data from its
internal `ietf-yang-library` module. Using the `-s` option in this case forces
validation in time of parsing the input file so it is expected to include also
the mandatory status data from the `ietf-yang-library` module.
@@ -192,7 +192,7 @@
Command and its output:
```
-> data -x config -s datastore.xml
+> data -t config -s datastore.xml
```
**Different data content types**
@@ -202,7 +202,7 @@
included or as a result of the <get-config> without the status data and
possibly filtered, so without specified subtrees), it must be possible to
specify which kind of data is going to be parsed. In `yanglint(1)`, this is done
-via `-x` option. The list of supported modes can be displayed by the `-h`
+via `-t` option. The list of supported modes can be displayed by the `-h`
option given to the `data` command. In general, the `auto` value lets the
`yanglint(1)` to recognize the data type automatically by the additional top-level
elements added to the parsed data. This is the same way as `pyang(1)` uses. Note,
@@ -213,7 +213,7 @@
Command and its output:
```
-> data -x edit config-missing-key.xml
+> data -t edit config-missing-key.xml
libyang[0]: Invalid (mixed names) opening (nam) and closing (name) element tags. (path: /nacm/groups/group/nam)
Failed to parse data.
```
@@ -223,7 +223,7 @@
Command and its output:
```
-> data -x edit config-unknown-element.xml
+> data -t edit config-unknown-element.xml
libyang[0]: Unknown element "denied-operations". (path: /ietf-netconf-acm:nacm/denied-operations)
Failed to parse data.
```
@@ -469,7 +469,7 @@
Command and its output:
```
> feature -e * ietf-ip
-> data -f json -x config data-ip.xml
+> data -f json -t config data-ip.xml
{
"ietf-interfaces:interfaces": {
"interface": [