]> xenbits.xensource.com Git - libvirt.git/commitdiff
vsh: Remove unused infrastructure for command completion
authorPeter Krempa <pkrempa@redhat.com>
Mon, 15 Apr 2024 09:45:14 +0000 (11:45 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 25 Apr 2024 12:13:19 +0000 (14:13 +0200)
Remove the old helpers which were used previously to pick which field to
complete.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh.c
tools/virt-admin.c
tools/vsh.c
tools/vsh.h

index 58ebb493fc60c0c5e16b6a1cedae702ef2246351..a958f2b82f569bc1c4a08ae9460aa7cc652b8733 100644 (file)
@@ -770,7 +770,7 @@ virshParseArgv(vshControl *ctl, int argc, char **argv)
         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);
         }
@@ -908,7 +908,7 @@ main(int argc, char **argv)
             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);
index a996923094d93167e6fa28ce7016ddfb3f04ddb3..18056180355de559f9e4ef42b9b6f12166e2e405 100644 (file)
@@ -1331,7 +1331,7 @@ vshAdmParseArgv(vshControl *ctl, int argc, char **argv)
         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);
         }
@@ -1558,7 +1558,7 @@ main(int argc, char **argv)
             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);
index 91d01cc73f84afbf9daf4cefdb7b5e33993967d7..f4c127222d2100ade5793d694761cfed92054f49 100644 (file)
@@ -1430,7 +1430,6 @@ struct _vshCommandParser {
                                  char **, bool);
     /* vshCommandStringGetArg() */
     char *pos;
-    const char *originalLine;
     size_t point;
     /* vshCommandArgvGetArg() */
     char **arg_pos;
@@ -1543,9 +1542,6 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
                             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)
@@ -1596,9 +1592,6 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
                 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)
@@ -1812,23 +1805,18 @@ vshCommandStringGetArg(vshControl *ctl, vshCommandParser *parser, char **res,
  * @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 };
 
@@ -1836,8 +1824,6 @@ vshCommandStringParse(vshControl *ctl,
         return false;
 
     parser.pos = cmdstr;
-    parser.originalLine = cmdstr;
-    parser.point = point;
     parser.getNextArg = vshCommandStringGetArg;
     return vshCommandParse(ctl, &parser, partial);
 }
@@ -2844,7 +2830,7 @@ vshReadlineParse(const char *text, int state)
 
         *(line + rl_point) = '\0';
 
-        vshCommandStringParse(NULL, line, &partial, rl_point);
+        vshCommandStringParse(NULL, line, &partial);
 
         if (partial) {
             cmd = partial->def;
index 04d7e163f1e4cace20b6937dbf35ababe57d41fc..479e6abaecb4e09f65d0fbb398649b0cb3a8d663 100644 (file)
@@ -149,8 +149,6 @@ struct _vshCmdOpt {
     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;
 };
 
@@ -292,7 +290,7 @@ int vshBlockJobOptionBandwidth(vshControl *ctl,
 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,