MCPcopy Create free account
hub / github.com/Kitware/VTK / showHelp

Function showHelp

ThirdParty/sqlite/vtksqlite/shell.c:25117–25207  ·  view source on GitHub ↗

** Output help text. ** ** 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. ** ** Return the number of matches. */

Source from the content-addressed store, hash-verified

25115** Return the number of matches.
25116*/
25117static int showHelp(FILE *out, const char *zPattern){
25118 int i = 0;
25119 int j = 0;
25120 int n = 0;
25121 char *zPat;
25122 if( zPattern==0
25123 || zPattern[0]=='0'
25124 || cli_strcmp(zPattern,"-a")==0
25125 || cli_strcmp(zPattern,"-all")==0
25126 || cli_strcmp(zPattern,"--all")==0
25127 ){
25128 enum HelpWanted { HW_NoCull = 0, HW_SummaryOnly = 1, HW_Undoc = 2 };
25129 enum HelpHave { HH_Undoc = 2, HH_Summary = 1, HH_More = 0 };
25130 /* Show all or most commands
25131 ** *zPattern==0 => summary of documented commands only
25132 ** *zPattern=='0' => whole help for undocumented commands
25133 ** Otherwise => whole help for documented commands
25134 */
25135 enum HelpWanted hw = HW_SummaryOnly;
25136 enum HelpHave hh = HH_More;
25137 if( zPattern!=0 ){
25138 hw = (*zPattern=='0')? HW_NoCull|HW_Undoc : HW_NoCull;
25139 }
25140 for(i=0; i<ArraySize(azHelp); i++){
25141 switch( azHelp[i][0] ){
25142 case ',':
25143 hh = HH_Summary|HH_Undoc;
25144 break;
25145 case '.':
25146 hh = HH_Summary;
25147 break;
25148 default:
25149 hh &= ~HH_Summary;
25150 break;
25151 }
25152 if( ((hw^hh)&HH_Undoc)==0 ){
25153 if( (hh&HH_Summary)!=0 ){
25154 sqlite3_fprintf(out, ".%s\n", azHelp[i]+1);
25155 ++n;
25156 }else if( (hw&HW_SummaryOnly)==0 ){
25157 sqlite3_fprintf(out, "%s\n", azHelp[i]);
25158 }
25159 }
25160 }
25161 }else{
25162 /* Seek documented commands for which zPattern is an exact prefix */
25163 zPat = sqlite3_mprintf(".%s*", zPattern);
25164 shell_check_oom(zPat);
25165 for(i=0; i<ArraySize(azHelp); i++){
25166 if( sqlite3_strglob(zPat, azHelp[i])==0 ){
25167 sqlite3_fprintf(out, "%s\n", azHelp[i]);
25168 j = i+1;
25169 n++;
25170 }
25171 }
25172 sqlite3_free(zPat);
25173 if( n ){
25174 if( n==1 ){

Callers 3

arUsageFunction · 0.85
recoverDatabaseCmdFunction · 0.85
do_meta_commandFunction · 0.85

Calls 3

cli_strcmpFunction · 0.85
sqlite3_fprintfFunction · 0.85
shell_check_oomFunction · 0.85

Tested by

no test coverage detected