From: larrybr Date: Sun, 23 Jan 2022 04:19:52 +0000 (+0000) Subject: Shell refinements, seeargs, booleans, undocumented commands X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8a6c538ed3f18bd8e34a02f7de374329eebc0a9d;p=thirdparty%2Fsqlite.git Shell refinements, seeargs, booleans, undocumented commands FossilOrigin-Name: 8735caf13fc7e30da2fc5dc90921acbb3109f965c63dbf69fa70ef19c02308c0 --- diff --git a/manifest b/manifest index 03151da748..8bf5c320ab 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Create\snew\sbranch\snamed\s"shell-tweaks" -D 2022-01-23T02:53:25.827 +C Shell\srefinements,\sseeargs,\sbooleans,\sundocumented\scommands +D 2022-01-23T04:19:52.352 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -553,7 +553,7 @@ F src/random.c 097dc8b31b8fba5a9aca1697aeb9fd82078ec91be734c16bffda620ced7ab83c F src/resolve.c 359bc0e445d427583d2ab6110433a5dc777f64a0ecdf8d24826d8b475233ead9 F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92 F src/select.c ab5717255420972e69b9b9ce4d1c4730fe82cfbdc14b7743e389a8bdb79ca027 -F src/shell.c.in 4690f216dc4da0c104a8fd9f9e12bec0483242e630324aa7a3ccd155922e346e +F src/shell.c.in 606bfe3ca0483b06c850da59b4fb4f47e16dfbee49422214267dd7c268d26fbf F src/sqlite.h.in 31c2c8d737814369bd3b71f3849c4a97ef7ede0aa3ce976ecb11632fa5f1f863 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 5d54cf13d3406d8eb65d921a0d3c349de6126b732e695e79ecd4830ce86b4f8a @@ -1941,11 +1941,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e4caf1e3932b1bd0dea072df7fc9458aed98c84ea397b6948b89292603949c41 -R 8c92b45cd50ac9ababc3056da5861966 -T *branch * shell-tweaks -T *sym-shell-tweaks * -T -sym-trunk * +P 3f13df296b7d623085d2abb1a84fb9117f79f8e653a35956266da83727eeecba +R 1835fab59c38083072a9387a8873dd19 U larrybr -Z f4eae8276717c6e4e00b20ded60f50ea +Z 6bc6450e96a876f9bc34f811c8b01b49 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 28d69ab21a..300911993a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3f13df296b7d623085d2abb1a84fb9117f79f8e653a35956266da83727eeecba \ No newline at end of file +8735caf13fc7e30da2fc5dc90921acbb3109f965c63dbf69fa70ef19c02308c0 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index c15d2e54d4..a5a30cb041 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4032,7 +4032,6 @@ static const char *(azHelp[]) = { ".binary on|off Turn binary output on or off. Default OFF", ".cd DIRECTORY Change the working directory to DIRECTORY", ".changes on|off Show number of rows changed by SQL", - ".check GLOB Fail if output since .testcase does not match", ".clone NEWDB Clone data into NEWDB from the existing database", ".connection [close] [#] Open or close an auxiliary database connection", ".databases List names and files of attached databases", @@ -4064,7 +4063,8 @@ static const char *(azHelp[]) = { " --help Show CMD details", ".fullschema ?--indent? Show schema and the content of sqlite_stat tables", ".headers on|off Turn display of headers on or off", - ".help ?-all? ?PATTERN? Show help text for PATTERN", + ".help ?PATTERN?|?-all? Show help for PATTERN or everything, or summarize", + " Repeat -all to see undocumented commands", ".import FILE TABLE Import data from FILE into TABLE", " Options:", " --ascii Use \\037 and \\036 as column and row separators", @@ -4212,9 +4212,6 @@ static const char *(azHelp[]) = { ".system CMD ARGS... Run CMD ARGS... in a system shell", #endif ".tables ?TABLE? List names of tables matching LIKE pattern TABLE", - ".testcase NAME Begin redirecting output to 'testcase-out.txt'", - ".testctrl CMD ... Run various sqlite3_test_control() operations", - " Run \".testctrl\" with no arguments for details", ".timeout MS Try opening locked tables for MS milliseconds", ".timer on|off Turn SQL timer on or off", #ifndef SQLITE_OMIT_TRACE @@ -4244,6 +4241,22 @@ static const char *(azHelp[]) = { " Negative values right-justify", }; +/* Like azHelp[], but for undocumented commands. */ +static const char *(azHelpUndoc[]) = { + "These undocumented commands are for internal testing.\n" + "They are subject to change without notice.\n" + ".check GLOB Fail if output since .testcase does not match", + ".seeargs Echo arguments separated or terminated by |", + ".selftest-boolean Check boolean translation", + ".selftest-integer Check integer conversion", + ".testcase NAME Begin output redirect to 'testcase-out.txt'", + ".testctrl CMD ... Run various sqlite3_test_control() operations", + " Run \".testctrl\" with no arguments for details", +}; + +/* This literal's value and address is used for help's workings. */ +static const char *zHelpAll = "-all"; + /* ** Output help text. ** @@ -4257,18 +4270,28 @@ static int showHelp(FILE *out, const char *zPattern){ int i = 0; int j = 0; int n = 0; + int nHelp = ArraySize(azHelp); + const char **azHelpText = azHelp; char *zPat; + if( zPattern==zHelpAll ){ + /* It's zHelpAll, show help for the undocumented commands. */ + nHelp = ArraySize(azHelpUndoc); + azHelpText = azHelpUndoc; + } if( zPattern==0 || zPattern[0]=='0' || strcmp(zPattern,"-a")==0 || strcmp(zPattern,"-all")==0 || strcmp(zPattern,"--all")==0 ){ - /* Show all commands, but only one line per command */ + /* Show all commands. + * If no pattern, only one line per command. + * If any --all-like pattern, show all help. + */ if( zPattern==0 ) zPattern = ""; - for(i=0; i=0; i++){} @@ -4980,11 +5010,8 @@ static int booleanValue(const char *zArg){ for(i=0; zArg[i]>='0' && zArg[i]<='9'; i++){} } if( i>0 && zArg[i]==0 ) return (int)(integerValue(zArg) & 0xffffffff); - if( sqlite3_stricmp(zArg, "on")==0 || sqlite3_stricmp(zArg,"yes")==0 ){ - return 1; - } - if( sqlite3_stricmp(zArg, "off")==0 || sqlite3_stricmp(zArg,"no")==0 ){ - return 0; + for( i=0; zBoolNames[i]!=0; ++i ){ + if( sqlite3_stricmp(zArg, zBoolNames[i])==0 ) return i&1; } utf8_printf(stderr, "ERROR: Not a boolean value: \"%s\". Assuming \"no\".\n", zArg); @@ -8372,11 +8399,19 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='h' && strncmp(azArg[0], "help", n)==0 ){ if( nArg>=2 ){ - n = showHelp(p->out, azArg[1]); + if( nArg==3 + && strcmp(azArg[1], zHelpAll)==0 && strcmp(azArg[2], zHelpAll)==0 ){ + /* Show the undocumented command help */ + n = showHelp(p->out, zHelpAll); + }else{ + /* Show such help as the pattern selects */ + n = showHelp(p->out, azArg[1]); + } if( n==0 ){ utf8_printf(p->out, "Nothing matches '%s'\n", azArg[1]); } }else{ + /* Show one-line summaries */ showHelp(p->out, 0); } }else @@ -9592,6 +9627,12 @@ static int do_meta_command(char *zLine, ShellState *p){ } }else + if( c=='s' && n==7 && strncmp(azArg[0], "seeargs", n)==0 ){ + for( n=1; nout, "%s%s", azArg[n], (n==nArg-1)? "|\n" : "|"); + } + }else + if( c=='s' && n==11 && strncmp(azArg[0], "selecttrace", n)==0 ){ unsigned int x = nArg>=2 ? (unsigned int)integerValue(azArg[1]) : 0xffffffff; sqlite3_test_control(SQLITE_TESTCTRL_TRACEFLAGS, 1, &x);