[libvirt] [PATCHv2 0/4] Another attempt at improving virsh autocompletion

Solly Ross sross at redhat.com
Wed Apr 2 01:34:12 UTC 2014


Version 2: Electric Boogaloo
Version 1: https://www.redhat.com/archives/libvir-list/2014-March/msg01898.html

This version of the patch introduces the following new things:

- Tests (a whole bunch of them, in fact)!

- A new `complete` command to run get newline-separated
  completion results from the command line

- Support for completing partial quotes
  (e.g. `virsh complete "fake-command ab \"i "`)

- Passing the syntax checks (sorry about that)

A brief overview of the patch set follows:

1. Extract parsing logic from the vshCommandParse
   so that it can be used elsewhere.  The new method
   returns states and sets passed in pointers.  Calling
   methods can interpret these states and deal with them
   as needed (completion ignores many, while
   vshCommandParse throws errors).

2. Implement (and test!) an improved completion
   engine with support for virsh quoting rules,
   flags, positional arguments, no duplication,
   and more.

3. Add (and test!) a method for retrieve a global
   vshControl object should readline be enabled.  This
   allows for "smart completion" of options like "domain".

4. Extract the domain listing code from virsh-domain-monitor,
   and move it to virsh-completer.  Implement a domain completer,
   which is then used for all the cases of "domain" options
   (note that it current does not have any flags specified for
   which commands should list active vs inactive domains,
   as this commit is mainly to allow people to test out
   "smart completion")

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

 po/POTFILES.in               |   1 +
 tests/virshtest.c            | 268 +++++++++++++
 tools/Makefile.am            |   3 +-
 tools/virsh-completer.c      | 355 +++++++++++++++++
 tools/virsh-completer.h      |  85 +++++
 tools/virsh-domain-monitor.c | 287 +-------------
 tools/virsh-domain.c         |  72 ++++
 tools/virsh-snapshot.c       |  11 +
 tools/virsh.c                | 880 +++++++++++++++++++++++++++++++++++++------
 tools/virsh.h                |  20 +
 10 files changed, 1582 insertions(+), 400 deletions(-)
 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