Going over my local git branches, I found old patch set which I was trying to get in
once.
Along guest IP address patches I feel like this one is desired as well and keeps
returning
to us from time to time.
What I think this feature should look like:
virsh # sta<TAB>
expands to:
virsh # start
Now, hitting <TAB> again (okay, several times actually) gives us a list of supported
options:
--autodestroy --bypass-cache --console --force-boot --paused
virsh # start --
Up to here, it's just current implementation. What I'd like to see is list of
(ideally shut off) domains:
--autodestroy --bypass-cache --console --force-boot --paused f17 f18
<...>
virsh # start --
The same applies to complete a single option as well. That is not (only) command based
completer,
but a option based one. IIRC, that was conclusion on my first approach as well. What
I've come up with so far is:
diff --git a/tools/virsh.h b/tools/virsh.h
index ab7161f..c7cdb3a 100644
--- a/tools/virsh.h
+++ b/tools/virsh.h
@@ -146,6 +146,8 @@ typedef struct _vshCmdOptDef vshCmdOptDef;
typedef struct _vshControl vshControl;
typedef struct _vshCtrlData vshCtrlData;
+typedef char ** (*vshCmdOptCompleter)
+ (const vshCmdDef *cmd, const char *optname, void *opaque);
/*
* vshCmdInfo -- name/value pair for information about command
*
@@ -162,11 +164,13 @@ struct _vshCmdInfo {
* vshCmdOptDef - command option definition
*/
struct _vshCmdOptDef {
- const char *name; /* the name of option, or NULL for list end */
- vshCmdOptType type; /* option type */
- unsigned int flags; /* flags */
- const char *help; /* non-NULL help string; or for VSH_OT_ALIAS
- * the name of a later public option */
+ const char *name; /* the name of option, or NULL for list end */
+ vshCmdOptType type; /* option type */
+ unsigned int flags; /* flags */
+ vshCmdOptCompleter completer; /* option arguments completer */
+ void *opaque; /* value to pass to @completer */
+ const char *help; /* non-NULL help string; or for VSH_OT_ALIAS
+ * the name of a later public option */
};
One of the biggest problem with this is - I'd have to change all of option
definitions
(add 'NULL, NULL, ' to all of them). Apart from huge impact, we still want command
based completer,
otherwise we would only complete:
f17 f18 <...>
virsh # start --domain <TAB>
Who's really typing '--domain'? The idea is to make users life easier, not
harder.
My aim to write this e-mail is:
1) let you know somebody is working on this
2) get your thoughts and opinions.
Michal