mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
vsh: Rewrite opt->type check in vshReadlineParse()
The vshReadlineParse() function is called whenever user hits <TAB><TAB>. If there is no command (or a partially written one), then a list of possible commands is printed to the user. But, if there is a command then its --options are generated. But obviously, we can not generate --options if there already is an --option that's expecting a value. For instance, consider: virsh # start --domain <TAB><TAB> In this case we want to call completer for --domain option, but that's a different story. Anyway, the way that we currently check whether --options list should be generated is checking the type of the last --option. If it isn't DATA, STRING, INT, or ARGV (all these expect a value), then we can generate --option list. Well, writing the condition this way is needlessly verbose and also prone to errors (see d9a320bf97 for example). We know that boolean type does not require a value. This leaves us with the only type that was not mentioned yet - VSH_OT_ALIAS. This is a special type for backwards compatibility and it refers to another --option which can be just any type. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
parent
9ad2cb6e73
commit
3cc6572fab
@ -2765,10 +2765,7 @@ vshReadlineParse(const char *text, int state)
|
||||
if (!cmd) {
|
||||
list = vshReadlineCommandGenerator(text);
|
||||
} else {
|
||||
if (!opt || (opt->type != VSH_OT_DATA &&
|
||||
opt->type != VSH_OT_STRING &&
|
||||
opt->type != VSH_OT_INT &&
|
||||
opt->type != VSH_OT_ARGV))
|
||||
if (!opt || opt->type == VSH_OT_BOOL)
|
||||
list = vshReadlineOptionsGenerator(text, cmd, partial);
|
||||
|
||||
if (opt && opt->completer) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user