Fix parsing issue with get

The bug was actually a little bit more complex, because not only the
completion was wrong, the actual parsing was wrong too. If the input
path was "ietf-netconf-monitoring:netconf-state/s", then nothing would
get successfully parsed, even though the first fragment was valid. This
is the reason why the completion was wrong: the CLI thought "okay I
didn't parse anything, so I'm going to give suggestions for top-level
nodes". That's why after completing "ietf-netconf-monitoring:netconf/s",
top-level nodes were suggested (because the parser esentially "get s"
begin completed).

As to why the bug actually happened was this: first, the getPath rule
would try a path with a key-less list at the end. That one failed,
because there's no list at the end, that's pretty simple. Then the
second alternative is tried. However, for some reason, Spirit doesn't
reset the input iterator after the first alternative fails. This is
because this "input iterator reset" isn't done automatically, but it is
usually done by the x3::rule class. If I wanted this functionality, I
would have to wrap my PathParser with this class. So, the second
alternative only has "s" (the last character in the input) to work with.

So, how I fixed this: first of all, I made the DataPathListEnd mode of
the parser not requiring to actually have the key-less list at the end.
That means there don't have to be two alternatives in `getPath`. This is
good, because less alternatives is always easier to work in Spirit (from
experience, especially when working with rules that have a vector
attribute).

Issue: https://tree.taiga.io/project/jktjkt-netconf-cli/issue/194
Change-Id: Id3a07d2acd20b1e8fa8c8946a55793d8995e5a62
2 files changed
tree: ce3869eb4e3ada9f4340e5d99204c1f7e2b73da1
  1. .clang-format
  2. .gitmodules
  3. .zuul.CzechLight-internal.yaml
  4. .zuul.public.yaml
  5. CMakeLists.txt
  6. Doxyfile.in
  7. LICENSE
  8. LICENSE.md
  9. README.md
  10. ci/
  11. cmake/
  12. docs/
  13. src/
  14. submodules/
  15. tests/
README.md

Console interface to NETCONF servers

This program provides an interactive console for working with YANG data. It can connect to NETCONF servers, and also talk to sysrepo locally.

Installation

For building, one needs:

  • A C++17 compiler
  • Boost version 1.69
  • cmake for managing the build
  • libyang for working with YANG models
  • libnetconf2 for connecting to NETCONF servers
  • sysrepo version 1.4.x for the local sysrepo backend, and for the comprehensive test suite
  • replxx which provides interactive line prompts
  • docopt for CLI option parsing
  • pkg-config for building
  • Doctest as a C++ unit test framework
  • trompeloeil for mock objects in C++

Use an exact commit of any dependencies as specified in submodules/dependencies/*.

The build process uses CMake. A quick-and-dirty build with no fancy options can be as simple as mkdir build && cd build && cmake .. && make && make install.

Bug Reporting

Issue reporting and feature requests are welcome via Taiga.io.

Development

We are using Gerrit for patch submission, code review and Continuous Integration (CI). Development roadmap and planning happens over Taiga.io.

Credits

Copyright © CESNET, https://www.cesnet.cz/ . Portions copyright © Faculty of Information Technology, Czech Technical University in Prague, https://fit.cvut.cz/ . Most of the code was written by Václav Kubernát (CESNET, formerly FIT ČVUT) and Jan Kundrát (CESNET). The project is distributed under the terms of the Apache 2.0 license.