When less help is more helpful

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

When less help is more helpful

Larry Brasfield
Lately, the SQLite CLI shell's help has become quite voluminous as features
have been added.  On my typical console window, it fills 3 screens, and so
I usually have to scroll back a screen or two to see the help I seek.  Also
inconveniently, the last several shell interactions get pushed well
off-screen at the same time, no longer easily seen.  This induced me to
enhance the .help command to accept an optional argument specifying a
subset of help to be blurted.  The argument need only be one or a few
leading characters in the shell command(s) of interest to reduce the blurt
to just what is wanted.

Here are the relevant "fossil diff" fragments, in case anybody likes this
change, or the shell developers decide it is worthwhile and easily done.
========
  /*
 ** Text of a help message
 */
-static char zHelp[] =
+static char* pzHelp[] = {
========
[For each command's help, comma appended to its last line. For example:]
-  ".help                  Show this message\n"
+  ".help ?for?            Show this message\n",
========
-;
+  NULL
+};
========
   if( c=='h' && strncmp(azArg[0], "help", n)==0 ){
-    utf8_printf(p->out, "%s", zHelp);
+    char * zHelp;
+    int nm = (nArg > 1)? strlen30(azArg[1]) : 0;
+    int i;
+    for (i = 0; 0 != (zHelp = pzHelp[i]); ++i){
+      if(nm > 0 && sqlite3_strnicmp(zHelp+1, azArg[1], nm) != 0)
+        continue;
+      utf8_printf(p->out, "%s", zHelp);
+    }
   }else
========
Cheers,
--
Larry Brasfield
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users