[libvirt] [PATCH 0/5] Another attempt at improving virsh autocompletion

Solly Ross sross at redhat.com
Sun Mar 30 02:36:08 UTC 2014


This patch set represents yet another attempt to improve the virsh
autocompletion.  When writing this patch, I tried to take into account
the comments on the previous attempt at autocompletion by Tomas Meszaros.

Specifically, it was reccomended that any completion use the existing
methods that virsh has in place to parse the partial line being completed.
When doing so, I found that I was duplicating a significant portion of the
code in vshCommandParse.  Since the comments on Tomas's code suggested
refactoring common code into a separate function, I attempted to do
so with vshCommandParse.  One of the primary issues with simply just
moving the parsing logic from vshCommandParse into a separate function
was that vshCommandParse throws errors when it encounters unknown or
invalid information.  While this is the correct behavior for parsing
a command to be executed, it is not appropriate for autocompletion.
Essentially, the new function represents one iteration of the main
loop from vshCommandParse.  However, instead of constructing a parsed
option or command object at the end, or returning errors, it returns
a "state" value and sets pointers.  Then, a calling function may choose
to deal with the state values (like vshCommandParse) or ignore most of
the state values (like the completion code, which ignores most state
and errors, as it is just interested in which flags have already been
used).  This is perhaps the most "dangerous" and controversial part
of the patch set, so I figured I'd get some feedback before progressing
any further.

The other significant changes in the patch set (besides richer
completion support) are as follows:

- completion no longer automatically falls back to readline's
  default filename completion.  Instead, if filename completion
  is desired, an option may be explicitly marked as requiring
  filename completion.

- when readline support is enable, a global vshControl object
  is made available by way of a macro/function.  When readline
  support is disabled, the global is not included and the macro
  simply returns NULL.  This global is required for smart completers.

- the code which is used by the "list" command has been moved
  from virsh-domain-monitor to virsh-completer.  This way,
  it is accessible to both the "list" command code and
  the domain completer.

Note that none of the options which use the domain completer
currently have flags set to indicate whether active or inactive
domains should be completed.  If this completion patch-set is
OKed, then I will go back and add these flags.  Currently,
the commit is there simply to make testing out the new completion
easier.

Solly Ross (5):
  Improve virsh autocompletion (extract parser)
  Improve virsh autocompletion (base framework)
  Improve virsh autocompletion (global ctl object)
  Improve virsh autocompletion (domain completer)
  Improve virsh autocompletion (enum completer macro)

 outgoing/0000-cover-letter.patch                   |   68 +
 ...prove-virsh-autocompletion-extract-parser.patch |  428 ++++++
 ...prove-virsh-autocompletion-base-framework.patch |  278 ++++
 ...ve-virsh-autocompletion-global-ctl-object.patch |  116 ++
 ...ove-virsh-autocompletion-domain-completer.patch | 1479 ++++++++++++++++++++
 ...virsh-autocompletion-enum-completer-macro.patch |  131 ++
 tools/Makefile.am                                  |    3 +-
 tools/virsh-completer.c                            |  353 +++++
 tools/virsh-completer.h                            |   86 ++
 tools/virsh-domain-monitor.c                       |  287 +---
 tools/virsh-domain.c                               |   72 +
 tools/virsh-snapshot.c                             |   11 +
 tools/virsh.c                                      |  517 +++++--
 tools/virsh.h                                      |   13 +
 14 files changed, 3447 insertions(+), 395 deletions(-)
 create mode 100644 outgoing/0000-cover-letter.patch
 create mode 100644 outgoing/0001-Improve-virsh-autocompletion-extract-parser.patch
 create mode 100644 outgoing/0002-Improve-virsh-autocompletion-base-framework.patch
 create mode 100644 outgoing/0003-Improve-virsh-autocompletion-global-ctl-object.patch
 create mode 100644 outgoing/0004-Improve-virsh-autocompletion-domain-completer.patch
 create mode 100644 outgoing/0005-Improve-virsh-autocompletion-enum-completer-macro.patch
 create mode 100644 tools/virsh-completer.c
 create mode 100644 tools/virsh-completer.h

-- 
1.8.3.2




More information about the libvir-list mailing list