diff options
-rw-r--r-- | manifest | 12 | ||||
-rw-r--r-- | manifest.uuid | 2 | ||||
-rw-r--r-- | src/shell.c.in | 157 |
3 files changed, 86 insertions, 85 deletions
@@ -1,5 +1,5 @@ -C Back\sout\sthe\s"low-quality\sindex"\squery\splanner\shack\sof\scheck-in\n[bcac937526d9a6ef].\s\sSubsequent\squery\splanner\senhancements\sfor\sdealing\nwith\sstar-queries\smake\sthat\schange\sunnecessary\sand\sthe\schange\swas\srecently\nfound\sto\scause\sa\sperformance\sregression\sin\san\sunrelated\squery.\nAlso\sfix\sa\stypo\sin\sa\sdebugging\smessage. -D 2025-05-14T16:40:05.375 +C Rework\sthe\sshowHelp()\sfunction\sin\sthe\sCLI\simplementation\sso\sthat\sits\npurpose\sand\soperation\sare\swell\sdescribed\sby\sthe\sheader\scommit.\s\sOmit\nthe\suse\sof\senums\sthat\scause\sissues\sfor\sMSVC\s2025. +D 2025-05-15T11:20:54.545 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -786,7 +786,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c d40fe18d7c2fd0339f5846ffcf7d6809866e380acdf14c76fb2af87e9fe13f64 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 1a5956231f7c57571288eaad61e5c37aaf0f3acb5c8a5ea0b896938166b62fa2 -F src/shell.c.in 2c904da4431fed365e7d5029b8cb2da46cb3e8cf8a09305d1478836a2301ea96 +F src/shell.c.in ba53a52dafb167ac6320703da741386c34fbcabe8c078a188bb9f89808e3ef8f F src/sqlite.h.in 22882ddd3a70751aa8864c81993ee4562ed54c2c508b6270f75e223ffee38e1b F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2207,8 +2207,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 53644c42c5ee40e905a72bb014515e5e30265577d543eeca09139800822b5b42 -R 59151c194fe4122ae75c7906b9cce51d +P e7dcf25efae364b7cdf9eb8265803c816c8b8557e4a7684da428badc6ffb3875 +R 8d7346d35de07e0adf7ff5f85eb83ae9 U drh -Z 6b734debe02b11e5124b69bb671a98d3 +Z c3facc97efa58229c1d101134ec23e8c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index eae3348ca..8efa15f86 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e7dcf25efae364b7cdf9eb8265803c816c8b8557e4a7684da428badc6ffb3875 +336ceeccc6f85bd78f4a26648af7edf9056d569a767b4120f125a02b2090a349 diff --git a/src/shell.c.in b/src/shell.c.in index 7af8f79b8..8660bd78a 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -5340,103 +5340,104 @@ static const char *(azHelp[]) = { }; /* -** Output help text. +** Output help text for commands that match zPattern. ** -** zPattern describes the set of commands for which help text is provided. -** If zPattern is NULL, then show all commands, but only give a one-line -** description of each. +** * If zPattern is NULL, then show all documented commands, but +** only give a one-line summary of each. ** -** Return the number of matches. +** * If zPattern is "-a" or "-all" or "--all" then show all help text +** for all commands except undocumented commands. +** +** * If zPattern is "0" then show all help for undocumented commands. +** Undocumented commands begin with "," instead of "." in the azHelp[] +** array. +** +** * If zPattern is a prefix for one or more documented commands, then +** show help for those commands. If only a single command matches the +** prefix, show the full text of the help. If multiple commands match, +** Only show just the first line of each. +** +** * Otherwise, show the complete text of any documented command for which +** zPattern is a LIKE match for any text within that command help +** text. +** +** Return the number commands that match zPattern. */ static int showHelp(FILE *out, const char *zPattern){ int i = 0; int j = 0; int n = 0; char *zPat; - if( zPattern==0 - || zPattern[0]=='0' - || cli_strcmp(zPattern,"-a")==0 - || cli_strcmp(zPattern,"-all")==0 - || cli_strcmp(zPattern,"--all")==0 + if( zPattern==0 ){ + /* Show just the first line for all help topics */ + zPattern = "[a-z]"; + }else if( cli_strcmp(zPattern,"-a")==0 + || cli_strcmp(zPattern,"-all")==0 + || cli_strcmp(zPattern,"--all")==0 ){ - enum HelpWanted { HW_NoCull = 0, HW_SummaryOnly = 1, HW_Undoc = 2 }; - enum HelpHave { HH_Undoc = 2, HH_Summary = 1, HH_More = 0 }; - /* Show all or most commands - ** *zPattern==0 => summary of documented commands only - ** *zPattern=='0' => whole help for undocumented commands - ** Otherwise => whole help for documented commands - */ - enum HelpWanted hw = HW_SummaryOnly; - enum HelpHave hh = HH_More; - if( zPattern!=0 ){ - hw = (*zPattern=='0')? HW_NoCull|HW_Undoc : HW_NoCull; - } + /* Show everything except undocumented commands */ + zPattern = "."; + }else if( cli_strcmp(zPattern,"0")==0 ){ + /* Show complete help text of undocumented commands */ + int show = 0; for(i=0; i<ArraySize(azHelp); i++){ - switch( azHelp[i][0] ){ - case ',': - hh = HH_Summary|HH_Undoc; - break; - case '.': - hh = HH_Summary; - break; - default: - hh &= ~HH_Summary; - break; - } - if( ((hw^hh)&HH_Undoc)==0 ){ - if( (hh&HH_Summary)!=0 ){ - sqlite3_fprintf(out, ".%s\n", azHelp[i]+1); - ++n; - }else if( (hw&HW_SummaryOnly)==0 ){ - sqlite3_fprintf(out, "%s\n", azHelp[i]); - } - } - } - }else{ - /* Seek documented commands for which zPattern is an exact prefix */ - zPat = sqlite3_mprintf(".%s*", zPattern); - shell_check_oom(zPat); - for(i=0; i<ArraySize(azHelp); i++){ - if( sqlite3_strglob(zPat, azHelp[i])==0 ){ - sqlite3_fprintf(out, "%s\n", azHelp[i]); - j = i+1; + if( azHelp[i][0]=='.' ){ + show = 0; + }else if( azHelp[i][0]==',' ){ + show = 1; + sqlite3_fprintf(out, ".%s\n", &azHelp[i][1]); n++; + }else if( show ){ + sqlite3_fprintf(out, "%s\n", azHelp[i]); } } - sqlite3_free(zPat); - if( n ){ - if( n==1 ){ - /* when zPattern is a prefix of exactly one command, then include - ** the details of that command, which should begin at offset j */ - while( j<ArraySize(azHelp)-1 && azHelp[j][0]==' ' ){ - sqlite3_fprintf(out, "%s\n", azHelp[j]); - j++; - } - } - return n; + return n; + } + + /* Seek documented commands for which zPattern is an exact prefix */ + zPat = sqlite3_mprintf(".%s*", zPattern); + shell_check_oom(zPat); + for(i=0; i<ArraySize(azHelp); i++){ + if( sqlite3_strglob(zPat, azHelp[i])==0 ){ + sqlite3_fprintf(out, "%s\n", azHelp[i]); + j = i+1; + n++; } - /* Look for documented commands that contain zPattern anywhere. - ** Show complete text of all documented commands that match. */ - zPat = sqlite3_mprintf("%%%s%%", zPattern); - shell_check_oom(zPat); - for(i=0; i<ArraySize(azHelp); i++){ - if( azHelp[i][0]==',' ){ - while( i<ArraySize(azHelp)-1 && azHelp[i+1][0]==' ' ) ++i; - continue; + } + sqlite3_free(zPat); + if( n ){ + if( n==1 ){ + /* when zPattern is a prefix of exactly one command, then include + ** the details of that command, which should begin at offset j */ + while( j<ArraySize(azHelp)-1 && azHelp[j][0]==' ' ){ + sqlite3_fprintf(out, "%s\n", azHelp[j]); + j++; } - if( azHelp[i][0]=='.' ) j = i; - if( sqlite3_strlike(zPat, azHelp[i], 0)==0 ){ + } + return n; + } + + /* Look for documented commands that contain zPattern anywhere. + ** Show complete text of all documented commands that match. */ + zPat = sqlite3_mprintf("%%%s%%", zPattern); + shell_check_oom(zPat); + for(i=0; i<ArraySize(azHelp); i++){ + if( azHelp[i][0]==',' ){ + while( i<ArraySize(azHelp)-1 && azHelp[i+1][0]==' ' ) ++i; + continue; + } + if( azHelp[i][0]=='.' ) j = i; + if( sqlite3_strlike(zPat, azHelp[i], 0)==0 ){ + sqlite3_fprintf(out, "%s\n", azHelp[j]); + while( j<ArraySize(azHelp)-1 && azHelp[j+1][0]==' ' ){ + j++; sqlite3_fprintf(out, "%s\n", azHelp[j]); - while( j<ArraySize(azHelp)-1 && azHelp[j+1][0]==' ' ){ - j++; - sqlite3_fprintf(out, "%s\n", azHelp[j]); - } - i = j; - n++; } + i = j; + n++; } - sqlite3_free(zPat); } + sqlite3_free(zPat); return n; } |