subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1683282 - /subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c
Date Wed, 03 Jun 2015 11:06:07 GMT
Author: julianfoad
Date: Wed Jun  3 11:06:07 2015
New Revision: 1683282

URL: http://svn.apache.org/r1683282
Log:
On the 'move-tracking-2' branch: Add command-line completion in 'svnmover'.

* subversion/svnmover/svnmover.c
  (linenoise_completion): New.
  (execute): Register the completion callback.

Modified:
    subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c

Modified: subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c
URL: http://svn.apache.org/viewvc/subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c?rev=1683282&r1=1683281&r2=1683282&view=diff
==============================================================================
--- subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c (original)
+++ subversion/branches/move-tracking-2/subversion/svnmover/svnmover.c Wed Jun  3 11:06:07
2015
@@ -50,6 +50,11 @@
 #include "private/svn_sorts_private.h"
 #include "private/svn_token.h"
 
+#define HAVE_LINENOISE
+#ifdef HAVE_LINENOISE
+#include "../libsvn_subr/linenoise/linenoise.h"
+#endif
+
 /* Version compatibility check */
 static svn_error_t *
 check_lib_versions(void)
@@ -2803,6 +2808,36 @@ parse_actions(apr_array_header_t **actio
   return SVN_NO_ERROR;
 }
 
+/* A command-line completion callback for the 'Line Noise' interactive
+ * prompting.
+ *
+ * This is called when the user presses the Tab key. It calculates the
+ * possible completions for the partial line BUF.
+ *
+ * ### So far, this only works on a single command keyword at the start
+ *     of the line.
+ */
+static void
+linenoise_completion(const char *buf, linenoiseCompletions *lc)
+{
+  int i;
+
+  for (i = 0; i < sizeof(action_defn) / sizeof(action_defn[0]); i++)
+    {
+      /* Suggest each command that matches (and is longer than) what the
+         user has already typed. Add a space. */
+      if (strncmp(buf, action_defn[i].name, strlen(buf)) == 0
+          && strlen(action_defn[i].name) > strlen(buf))
+        {
+          static char completion[100];
+
+          apr_cpystrn(completion, action_defn[i].name, 99);
+          strcat(completion, " ");
+          linenoiseAddCompletion(lc, completion);
+        }
+    }
+}
+
 /* Display a prompt, read a line of input and split it into words.
  *
  * Set *WORDS to null if input is cancelled (by ctrl-C for example).
@@ -3119,6 +3154,11 @@ sub_main(int *exit_code, int argc, const
                           || extra_args_file
                           || non_interactive);
 
+  if (interactive_actions)
+    {
+      linenoiseSetCompletionCallback(linenoise_completion);
+    }
+
   SVN_ERR(wc_create(&wc,
                     anchor_url, base_revision,
                     ctx, pool, pool));



Mime
View raw message