mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
qemu-io: add command completion
Autocomplete qemu-io commands at the interactive prompt. Note this only completes command names and not their options. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
0cf17e1817
commit
4694020d3c
3 changed files with 25 additions and 1 deletions
|
@ -94,6 +94,21 @@ static const cmdinfo_t *find_command(const char *cmd)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* Invoke fn() for commands with a matching prefix */
|
||||
void qemuio_complete_command(const char *input,
|
||||
void (*fn)(const char *cmd, void *opaque),
|
||||
void *opaque)
|
||||
{
|
||||
cmdinfo_t *ct;
|
||||
size_t input_len = strlen(input);
|
||||
|
||||
for (ct = cmdtab; ct < &cmdtab[ncmds]; ct++) {
|
||||
if (strncmp(input, ct->name, input_len) == 0) {
|
||||
fn(ct->name, opaque);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static char **breakline(char *input, int *count)
|
||||
{
|
||||
int c = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue