Closed wisotzky closed 7 years ago
This is precisely the purpose of the -d flag.
Extra work to parse the query with any kind of escaping would add complexity that doesn't seem justified.
It does not add significant extra complexity.
Cross-check with my gNMI subscription tool in python https://github.com/nokia/pygnmi which support escaping. The coding effort is similar to having the delimiter configurable.
Please keep in mind, that if '/' is not working, people typically start to play around "," (comma) or ";" (semicolon). The issue is, that comma is already used by gnmi_cli to allow multiple queries by the same call. And semicolon is interpret by UNIX shell (e.g. bash). Same also would be true about backslash. Before playing around too much with separators that work, it is really recommended just to ignore separators within square brackets.
Maybe worth adding... In my python tool I am using the following code:
if path:
if path[0]=='/':
if path[-1]=='/':
return re.split('''/(?=(?:[^\[\]]|\[[^\[\]]+\])*$)''', path)[1:-1]
else:
return re.split('''/(?=(?:[^\[\]]|\[[^\[\]]+\])*$)''', path)[1:]
else:
if path[-1]=='/':
return re.split('''/(?=(?:[^\[\]]|\[[^\[\]]+\])*$)''', path)[:-1]
else:
return re.split('''/(?=(?:[^\[\]]|\[[^\[\]]+\])*$)''', path)
return []
While this looks complex, it allows people to have a bit of flexibility. It basically allows people to use a slash at the beginning of the path expression - which some people like to do for compatibility of xpath expressions. Also it ignores a slash at the end, as I am using the same method for the prefix - and some people using a slash at the end of prefixes. Finally I am returning the empty list [] in case of a zero-length string, as running queries against the root element in gNMI has changed to [] but was [""] before.
fixed by 3d0217d986e4c6966729765683a38a6073dc1028
Looks good now. Thx
Example:
While this one is working nicely:
It would be desired, if the any slash characters "/" within square brackets "[...]" are not used as delimiter.