the original version:
https://www.redhat.com/archives/libvir-list/2016-September/msg00312.html
v2:
https://www.redhat.com/archives/libvir-list/2016-September/msg00380.html
Since this series (compared to v2) does a tiny bit of refactor (tweaking might
be a better word in this case) as well, I was also looking into refactoring the
parser in vsh.c....again...And again I gave up on doing that (this time a lot
faster though) because that would mean to rewrite a lot of code mainly to enable
usage of our virString* methods. I also found an ANSI C GNU-styled command line
parser library [1] which might even cope with our command and option aliases
(I didn't look into that much though, so take it with a grain of salt).
However, though looking good, it would most likely hit the wall once it
encountered our "multi-command" feature in the interactive shell mode :(
[1]
http://argtable.sourceforge.net/
since v1:
- tweaked the virsh-self-test so that it also checks the aliased commands
instead of skipping them (since there was a good reason for that before
the changes this series introduces)
- patches (now) 7-8 remained untouched
since v2:
- Michal was indeed right about having a proper check for missing aliases
which would eventually result in a reasonable internal error
- so the check was put into vshCmddefCheckInternals, but that function
should not be called from within vshCmddefOptParse because it's not just
about checking the .opts but the overall command structure and at the time
of parsing the arguments we should already know whether the command
structure is valid or not
- since vshCmddefOptParse has been split once again, merge it with
vshCmddefOptFill and drop the latter
Erik Skultety (8):
vsh: Fix NULL dereference leading to SIGSEGV if a command is missing
'.info'
vsh: vshCmddefHelp: Drop the unnecessary 'else' branch
vsh: vshCmddefHelp: Retrieve command info after we know the command is
non-NULL
vsh: Extract vshCmddefCheckInternals from vshCmddefOptParse
vsh: discard vshCmddefOptFill and move its body to vshCmddefOptParse
virt-admin: Tweak command parsing logic so that aliases point to new
commands
virt-admin: Add some command aliases to provide syntax sugar over ugly
commands
virt-admin: Replace the (now) aliases with new command names in the
man page
tools/virsh-nodedev.c | 6 +-
tools/virsh.pod | 2 -
tools/virt-admin.c | 24 +++++
tools/virt-admin.pod | 30 +++---
tools/vsh.c | 280 ++++++++++++++++++++++++++------------------------
tools/vsh.h | 4 +-
6 files changed, 191 insertions(+), 155 deletions(-)
--
2.5.5