ctl->imode = false;
if (argc - optind == 1) {
vshDebug(ctl, VSH_ERR_INFO, "commands: \"%s\"\n", argv[optind]);
- return vshCommandStringParse(ctl, argv[optind], NULL, 0);
+ return vshCommandStringParse(ctl, argv[optind], NULL);
} else {
return vshCommandArgvParse(ctl, argc - optind, argv + optind);
}
if (*ctl->cmdstr) {
vshReadlineHistoryAdd(ctl->cmdstr);
- if (vshCommandStringParse(ctl, ctl->cmdstr, NULL, 0))
+ if (vshCommandStringParse(ctl, ctl->cmdstr, NULL))
vshCommandRun(ctl, ctl->cmd);
}
VIR_FREE(ctl->cmdstr);
ctl->imode = false;
if (argc - optind == 1) {
vshDebug(ctl, VSH_ERR_INFO, "commands: \"%s\"\n", argv[optind]);
- return vshCommandStringParse(ctl, argv[optind], NULL, 0);
+ return vshCommandStringParse(ctl, argv[optind], NULL);
} else {
return vshCommandArgvParse(ctl, argc - optind, argv + optind);
}
if (*ctl->cmdstr) {
vshReadlineHistoryAdd(ctl->cmdstr);
- if (vshCommandStringParse(ctl, ctl->cmdstr, NULL, 0))
+ if (vshCommandStringParse(ctl, ctl->cmdstr, NULL))
vshCommandRun(ctl, ctl->cmd);
}
VIR_FREE(ctl->cmdstr);
char **, bool);
/* vshCommandStringGetArg() */
char *pos;
- const char *originalLine;
size_t point;
/* vshCommandArgvGetArg() */
char **arg_pos;
arg->data = g_steal_pointer(&tkdata);
arg->next = NULL;
- if (parser->pos - parser->originalLine == parser->point - 1)
- arg->completeThis = true;
-
if (!first)
first = arg;
if (last)
arg->data = g_steal_pointer(&tkdata);
arg->next = NULL;
- if (parser->pos - parser->originalLine == parser->point)
- arg->completeThis = true;
-
if (!first)
first = arg;
if (last)
* @ctl virsh control structure
* @cmdstr: string to parse
* @partial: store partially parsed command here
- * @point: position of cursor (rl_point)
*
* Parse given string @cmdstr as a command and store it under
* @ctl->cmd. For readline completion, if @partial is not NULL on
* the input then errors in parsing are ignored (because user is
* still in progress of writing the command string) and partially
* parsed command is stored at *@partial (caller has to free it
- * afterwards). Among with @partial, caller must set @point which
- * is the position of cursor in @cmdstr (offset, numbered from 1).
- * Parser will then set @completeThis attribute to true for the
- * vshCmdOpt that appeared under the cursor.
+ * afterwards).
*/
bool
vshCommandStringParse(vshControl *ctl,
char *cmdstr,
- vshCmd **partial,
- size_t point)
+ vshCmd **partial)
{
vshCommandParser parser = { 0 };
return false;
parser.pos = cmdstr;
- parser.originalLine = cmdstr;
- parser.point = point;
parser.getNextArg = vshCommandStringGetArg;
return vshCommandParse(ctl, &parser, partial);
}
*(line + rl_point) = '\0';
- vshCommandStringParse(NULL, line, &partial, rl_point);
+ vshCommandStringParse(NULL, line, &partial);
if (partial) {
cmd = partial->def;
char *data; /* allocated data, or NULL for bool option */
const char **argv; /* for VSH_OT_ARGV, the list of options */
char *argvstr; /* space-joined @argv */
- bool completeThis; /* true if this is the option user's wishing to
- autocomplete */
vshCmdOpt *next;
};
bool vshCommandOptBool(const vshCmd *cmd, const char *name);
bool vshCommandRun(vshControl *ctl, const vshCmd *cmd);
bool vshCommandStringParse(vshControl *ctl, char *cmdstr,
- vshCmd **partial, size_t point);
+ vshCmd **partial);
const char **
vshCommandOptArgv(const vshCmd *cmd,