This series implements advanced auto-completion for virsh. Using custom option
completers (examples in 3/5, 4/5 and 5/5), it is possible to further complete
any option with defined completer function.
Option completer function should return list of completed names for each desired
option. Using C99 initialization, it is easy to enable specific completer for
any option. For example, when we want domain completer for "start --domain"
option, we write vshDomainCompleter() and along with desired flags, initialize
targeted opts struct.
static const vshCmdOptDef opts_start[] = {
{.name = "domain",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("name of the inactive domain"),
.completer = vshDomainCompleter,
.completer_flags = VIR_CONNECT_LIST_DOMAINS_INACTIVE |
VIR_CONNECT_LIST_DOMAINS_PERSISTENT
},
Auto-completion itself then works like this:
virsh # start --domain <TAB>
domain1 domain2 domainN
virsh # vol-key <TAB>
--help --pool --vol vol1 vol2
---
v4:
* rewritten to use only option completers
v3:
https://www.redhat.com/archives/libvir-list/2013-August/msg01294.html
v2:
https://www.redhat.com/archives/libvir-list/2013-August/msg00992.html
v1:
https://www.redhat.com/archives/libvir-list/2013-August/msg00371.html
Tomas Meszaros (5):
virsh: Add vshCmdCompleter and vshOptCompleter
virsh: Improve readline generators and readline completion
virsh: Add vshDomainCompleter
virsh: Add vshSuspendTargetCompleter
virsh: Add vshRebootShutdownModeCompleter
tools/virsh-domain-monitor.c | 52 +++++--
tools/virsh-domain.c | 310 +++++++++++++++++++++++++++++---------
tools/virsh-snapshot.c | 50 +++++--
tools/virsh.c | 350 +++++++++++++++++++++++++++++++++++++++----
tools/virsh.h | 8 +
5 files changed, 648 insertions(+), 122 deletions(-)
--
1.8.3.1