Fossil SCM

Help improvements: (1) New command "fossil usage COMMAND" that prints just a summary of the command-line syntax. (2) "fossil help COMMAND SUBCOMMAND" shows just the help for SUBCOMMAND for commands line "bisect" or "push" that have lots of subcommands.

drh 2025-02-28 17:26 trunk
Commit baeffb9d31ad63b079e87ca648f21f8081c37825f1d5fbc94edc412a40711ad6
1 file changed +134 -19
+134 -19
--- src/dispatch.c
+++ src/dispatch.c
@@ -525,10 +525,14 @@
525525
** Format help text for TTY display.
526526
*/
527527
static void help_to_text(const char *zHelp, Blob *pText){
528528
int i, x;
529529
char c;
530
+ if( zHelp[0]=='>' ){
531
+ blob_appendf(pText, "Usage:");
532
+ zHelp++;
533
+ }
530534
for(i=0; (c = zHelp[i])!=0; i++){
531535
if( c=='%' && strncmp(zHelp+i,"%fossil",7)==0 ){
532536
if( i>0 ) blob_append(pText, zHelp, i);
533537
blob_append(pText, "fossil", 6);
534538
zHelp += i+7;
@@ -1059,10 +1063,80 @@
10591063
}
10601064
@ </dl>
10611065
blob_reset(&buf);
10621066
style_finish_page();
10631067
}
1068
+
1069
+/*
1070
+** Input z[] is help text for zTopic. If zTopic has sub-command zSub,
1071
+** then cut out all portions of the original help text that do not
1072
+** directly pertain to zSub and write the zSub-relevant parts into
1073
+** pOut.
1074
+**
1075
+** Return the number of lines of z[] written into pOut. A return of
1076
+** zero means no simplification occurred.
1077
+*/
1078
+static int simplify_to_subtopic(
1079
+ const char *z, /* Full original help text */
1080
+ Blob *pOut, /* Write simplified help text here */
1081
+ const char *zTopic, /* TOPIC */
1082
+ const char *zSubtopic /* SUBTOPIC */
1083
+){
1084
+ Blob in, line;
1085
+ int n = 0;
1086
+ char *zGlob = mprintf("> fossil %s *%s*", zTopic, zSubtopic);
1087
+
1088
+ blob_init(&in, z, -1);
1089
+ while( blob_line(&in, &line) ){
1090
+ if( sqlite3_strglob(zGlob, blob_str(&line))==0 ){
1091
+ blob_appendb(pOut, &line);
1092
+ n++;
1093
+ while( blob_line(&in, &line) && blob_str(&line)[0]!='>' ){
1094
+ blob_appendb(pOut, &line);
1095
+ n++;
1096
+ }
1097
+ break;
1098
+ }
1099
+ }
1100
+ fossil_free(zGlob);
1101
+ if( n ) blob_trim(pOut);
1102
+ return n;
1103
+ return 0;
1104
+}
1105
+
1106
+/*
1107
+** Input z[] is help text for a command zTopic. Write into pOut all lines of
1108
+** z[] that show the command-line syntax for that command. Lines written
1109
+** to pOut are lines that begin with out of:
1110
+**
1111
+** Usage:
1112
+** or:
1113
+** > fossil TOPIC
1114
+**
1115
+** Return the number of lines written into pOut.
1116
+*/
1117
+static int simplify_to_usage(
1118
+ const char *z, /* Full original help text */
1119
+ Blob *pOut, /* Write simplified help text here */
1120
+ const char *zTopic /* The command for which z[] is full help text */
1121
+){
1122
+ ReCompiled *pRe = 0;
1123
+ Blob in, line;
1124
+ int n = 0;
1125
+
1126
+ re_compile(&pRe, "^(Usage: | *[Oo]r: +%fossi |> fossil )", 0);
1127
+ blob_init(&in, z, -1);
1128
+ while( blob_line(&in, &line) ){
1129
+ if( re_match(pRe, (unsigned char*)blob_str(&line), blob_strlen(&line)) ){
1130
+ blob_appendb(pOut, &line);
1131
+ n++;
1132
+ }
1133
+ }
1134
+ re_free(pRe);
1135
+ if( n ) blob_trim(pOut);
1136
+ return n;
1137
+}
10641138
10651139
static void multi_column_list(const char **azWord, int nWord){
10661140
int i, j, len;
10671141
int mxLen = 0;
10681142
int nCol;
@@ -1147,54 +1221,75 @@
11471221
@ --systemtrace Trace calls to system()
11481222
@ -U|--user USER Make the default user be USER
11491223
@ --utc Display times using UTC
11501224
@ --vfs NAME Cause SQLite to use the NAME VFS
11511225
;
1226
+
1227
+/*
1228
+** COMMAND: usage
1229
+**
1230
+** Usage: %fossil usage COMMAND [SUBCOMMAND]
1231
+**
1232
+** Show succinct usage instruction for a Fossil command. Shorthand
1233
+** for "fossil help --usage COMMAND [SUBCOMMAND]"
1234
+*/
1235
+void usage_cmd(void){
1236
+ help_cmd();
1237
+}
11521238
11531239
/*
11541240
** COMMAND: help
11551241
**
1156
-** Usage: %fossil help [OPTIONS] [TOPIC]
1242
+** Usage: %fossil help [OPTIONS] [TOPIC] [SUBCOMMAND]
11571243
**
11581244
** Display information on how to use TOPIC, which may be a command, webpage, or
11591245
** setting. Webpage names begin with "/". If TOPIC is omitted, a list of
11601246
** topics is returned.
11611247
**
11621248
** The following options can be used when TOPIC is omitted:
11631249
**
11641250
** -a|--all List both common and auxiliary commands
1251
+** -e|--everything List all help on all topics
1252
+** -f|--full List full set of commands (including auxiliary
1253
+** and unsupported "test" commands), options,
1254
+** settings, and web pages
11651255
** -o|--options List command-line options common to all commands
11661256
** -s|--setting List setting names
11671257
** -t|--test List unsupported "test" commands
11681258
** -v|--verbose List both names and help text
11691259
** -x|--aux List only auxiliary commands
11701260
** -w|--www List all web pages
1171
-** -f|--full List full set of commands (including auxiliary
1172
-** and unsupported "test" commands), options,
1173
-** settings, and web pages
1174
-** -e|--everything List all help on all topics
11751261
**
11761262
** These options can be used when TOPIC is present:
11771263
**
1178
-** -h|--html Format output as HTML rather than plain text
11791264
** -c|--commands Restrict TOPIC search to commands
1265
+** -h|--html Format output as HTML rather than plain text
1266
+** --raw Output raw, unformatted help text
1267
+** -u|--usage Show a succinct usage summary, not full help text
11801268
*/
11811269
void help_cmd(void){
11821270
int rc;
1183
- int mask = CMDFLAG_ANY;
1184
- int isPage = 0;
1185
- int verboseFlag = 0;
1186
- int commandsFlag = 0;
1187
- const char *z;
1188
- const char *zCmdOrPage;
1189
- const CmdOrPage *pCmd = 0;
1190
- int useHtml = 0;
1191
- const char *zTopic;
1192
- Blob txt;
1271
+ int mask = CMDFLAG_ANY; /* Mask of help topic types */
1272
+ int isPage = 0; /* True if TOPIC is a page */
1273
+ int verboseFlag = 0; /* -v option */
1274
+ int commandsFlag = 0; /* -c option */
1275
+ const char *z; /* Original, untranslated help text */
1276
+ const char *zCmdOrPage; /* "command" or "page" or "setting" */
1277
+ const CmdOrPage *pCmd = 0; /* ptr to aCommand[] entry for TOPIC */
1278
+ int useHtml = 0; /* -h option */
1279
+ int bUsage = g.zCmdName[0]=='u'; /* --usage or "fossil usage TOPIC" */
1280
+ int bRaw; /* --raw option */
1281
+ const char *zTopic; /* TOPIC argument */
1282
+ const char *zSubtopic = 0; /* SUBTOPIC argument */
1283
+ Blob subtext1, subtext2; /* Subsets of z[] containing subtopic/usage */
1284
+ Blob txt; /* Text after rendering */
1285
+
11931286
verboseFlag = find_option("verbose","v",0)!=0;
11941287
commandsFlag = find_option("commands","c",0)!=0;
11951288
useHtml = find_option("html","h",0)!=0;
1289
+ bRaw = find_option("raw",0,0)!=0;
1290
+ if( find_option("usage","u",0)!=0 ) bUsage = 1;
11961291
if( find_option("options","o",0) ){
11971292
fossil_print("%s", zOptions);
11981293
return;
11991294
}
12001295
else if( find_option("all","a",0) ){
@@ -1249,10 +1344,11 @@
12491344
command_list(CMDFLAG_1ST_TIER,verboseFlag,useHtml);
12501345
if( !verboseFlag ) version_cmd();
12511346
return;
12521347
}
12531348
zTopic = g.argv[2];
1349
+ zSubtopic = g.argc>=4 ? g.argv[3] : 0;
12541350
isPage = ('/' == zTopic[0]) ? 1 : 0;
12551351
if(isPage){
12561352
zCmdOrPage = "page";
12571353
}else if( commandsFlag ){
12581354
mask = CMDFLAG_COMMAND;
@@ -1273,23 +1369,38 @@
12731369
fossil_print("Did you mean one of these TOPICs:\n");
12741370
n = dispatch_approx_match(g.argv[2], 5, az);
12751371
for(i=0; i<n; i++){
12761372
fossil_print(" * %s\n", az[i]);
12771373
}
1278
- fossil_print("Also consider using:\n");
1374
+ fossil_print("Other commands to try:\n");
12791375
fossil_print(" fossil search -h PATTERN ;# search all help text\n");
12801376
fossil_print(" fossil help -a ;# show all commands\n");
12811377
fossil_print(" fossil help -w ;# show all web-pages\n");
12821378
fossil_print(" fossil help -s ;# show all settings\n");
12831379
fossil_print(" fossil help -o ;# show global options\n");
1284
- fossil_exit(1);
1380
+ return;
12851381
}
1382
+ blob_init(&subtext1, 0, 0);
1383
+ blob_init(&subtext2, 0, 0);
12861384
z = pCmd->zHelp;
12871385
if( z==0 ){
12881386
fossil_fatal("no help available for the %s %s",
12891387
pCmd->zName, zCmdOrPage);
12901388
}
1389
+ if( zSubtopic!=0 ){
1390
+ if( simplify_to_subtopic(z, &subtext1, zTopic, zSubtopic) ){
1391
+ z = blob_str(&subtext1);
1392
+ }else{
1393
+ fossil_print("No subtopic \"%s\" for \"%s\".\n", zTopic, zSubtopic);
1394
+ if( strstr(z, "Usage:")!=0 || strstr(z, "\n> fossil")!=0 ){
1395
+ bUsage = 1;
1396
+ }
1397
+ }
1398
+ }
1399
+ if( bUsage && simplify_to_usage(z, &subtext2, zTopic) ){
1400
+ z = blob_str(&subtext2);
1401
+ }
12911402
if( pCmd->eCmdFlags & CMDFLAG_SETTING ){
12921403
const Setting *pSetting = db_find_setting(pCmd->zName, 0);
12931404
char *zDflt = 0;
12941405
if( pSetting!=0 && pSetting->def!=0 && *pSetting->def!=0 ){
12951406
zDflt = mprintf(" (default: %s)", pSetting->def);
@@ -1299,17 +1410,21 @@
12991410
(pCmd->eCmdFlags & CMDFLAG_VERSIONABLE)!=0 ? " (versionable)" : ""
13001411
);
13011412
fossil_free(zDflt);
13021413
}
13031414
blob_init(&txt, 0, 0);
1304
- if( useHtml ){
1415
+ if( bRaw ){
1416
+ blob_append(&txt, z, -1);
1417
+ }else if( useHtml ){
13051418
help_to_html(z, &txt);
13061419
}else{
13071420
help_to_text(z, &txt);
13081421
}
13091422
fossil_print("%s\n", blob_str(&txt));
13101423
blob_reset(&txt);
1424
+ blob_reset(&subtext1);
1425
+ blob_reset(&subtext2);
13111426
}
13121427
13131428
/*
13141429
** Return a pointer to the setting information array.
13151430
**
13161431
--- src/dispatch.c
+++ src/dispatch.c
@@ -525,10 +525,14 @@
525 ** Format help text for TTY display.
526 */
527 static void help_to_text(const char *zHelp, Blob *pText){
528 int i, x;
529 char c;
 
 
 
 
530 for(i=0; (c = zHelp[i])!=0; i++){
531 if( c=='%' && strncmp(zHelp+i,"%fossil",7)==0 ){
532 if( i>0 ) blob_append(pText, zHelp, i);
533 blob_append(pText, "fossil", 6);
534 zHelp += i+7;
@@ -1059,10 +1063,80 @@
1059 }
1060 @ </dl>
1061 blob_reset(&buf);
1062 style_finish_page();
1063 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1064
1065 static void multi_column_list(const char **azWord, int nWord){
1066 int i, j, len;
1067 int mxLen = 0;
1068 int nCol;
@@ -1147,54 +1221,75 @@
1147 @ --systemtrace Trace calls to system()
1148 @ -U|--user USER Make the default user be USER
1149 @ --utc Display times using UTC
1150 @ --vfs NAME Cause SQLite to use the NAME VFS
1151 ;
 
 
 
 
 
 
 
 
 
 
 
 
1152
1153 /*
1154 ** COMMAND: help
1155 **
1156 ** Usage: %fossil help [OPTIONS] [TOPIC]
1157 **
1158 ** Display information on how to use TOPIC, which may be a command, webpage, or
1159 ** setting. Webpage names begin with "/". If TOPIC is omitted, a list of
1160 ** topics is returned.
1161 **
1162 ** The following options can be used when TOPIC is omitted:
1163 **
1164 ** -a|--all List both common and auxiliary commands
 
 
 
 
1165 ** -o|--options List command-line options common to all commands
1166 ** -s|--setting List setting names
1167 ** -t|--test List unsupported "test" commands
1168 ** -v|--verbose List both names and help text
1169 ** -x|--aux List only auxiliary commands
1170 ** -w|--www List all web pages
1171 ** -f|--full List full set of commands (including auxiliary
1172 ** and unsupported "test" commands), options,
1173 ** settings, and web pages
1174 ** -e|--everything List all help on all topics
1175 **
1176 ** These options can be used when TOPIC is present:
1177 **
1178 ** -h|--html Format output as HTML rather than plain text
1179 ** -c|--commands Restrict TOPIC search to commands
 
 
 
1180 */
1181 void help_cmd(void){
1182 int rc;
1183 int mask = CMDFLAG_ANY;
1184 int isPage = 0;
1185 int verboseFlag = 0;
1186 int commandsFlag = 0;
1187 const char *z;
1188 const char *zCmdOrPage;
1189 const CmdOrPage *pCmd = 0;
1190 int useHtml = 0;
1191 const char *zTopic;
1192 Blob txt;
 
 
 
 
 
1193 verboseFlag = find_option("verbose","v",0)!=0;
1194 commandsFlag = find_option("commands","c",0)!=0;
1195 useHtml = find_option("html","h",0)!=0;
 
 
1196 if( find_option("options","o",0) ){
1197 fossil_print("%s", zOptions);
1198 return;
1199 }
1200 else if( find_option("all","a",0) ){
@@ -1249,10 +1344,11 @@
1249 command_list(CMDFLAG_1ST_TIER,verboseFlag,useHtml);
1250 if( !verboseFlag ) version_cmd();
1251 return;
1252 }
1253 zTopic = g.argv[2];
 
1254 isPage = ('/' == zTopic[0]) ? 1 : 0;
1255 if(isPage){
1256 zCmdOrPage = "page";
1257 }else if( commandsFlag ){
1258 mask = CMDFLAG_COMMAND;
@@ -1273,23 +1369,38 @@
1273 fossil_print("Did you mean one of these TOPICs:\n");
1274 n = dispatch_approx_match(g.argv[2], 5, az);
1275 for(i=0; i<n; i++){
1276 fossil_print(" * %s\n", az[i]);
1277 }
1278 fossil_print("Also consider using:\n");
1279 fossil_print(" fossil search -h PATTERN ;# search all help text\n");
1280 fossil_print(" fossil help -a ;# show all commands\n");
1281 fossil_print(" fossil help -w ;# show all web-pages\n");
1282 fossil_print(" fossil help -s ;# show all settings\n");
1283 fossil_print(" fossil help -o ;# show global options\n");
1284 fossil_exit(1);
1285 }
 
 
1286 z = pCmd->zHelp;
1287 if( z==0 ){
1288 fossil_fatal("no help available for the %s %s",
1289 pCmd->zName, zCmdOrPage);
1290 }
 
 
 
 
 
 
 
 
 
 
 
 
 
1291 if( pCmd->eCmdFlags & CMDFLAG_SETTING ){
1292 const Setting *pSetting = db_find_setting(pCmd->zName, 0);
1293 char *zDflt = 0;
1294 if( pSetting!=0 && pSetting->def!=0 && *pSetting->def!=0 ){
1295 zDflt = mprintf(" (default: %s)", pSetting->def);
@@ -1299,17 +1410,21 @@
1299 (pCmd->eCmdFlags & CMDFLAG_VERSIONABLE)!=0 ? " (versionable)" : ""
1300 );
1301 fossil_free(zDflt);
1302 }
1303 blob_init(&txt, 0, 0);
1304 if( useHtml ){
 
 
1305 help_to_html(z, &txt);
1306 }else{
1307 help_to_text(z, &txt);
1308 }
1309 fossil_print("%s\n", blob_str(&txt));
1310 blob_reset(&txt);
 
 
1311 }
1312
1313 /*
1314 ** Return a pointer to the setting information array.
1315 **
1316
--- src/dispatch.c
+++ src/dispatch.c
@@ -525,10 +525,14 @@
525 ** Format help text for TTY display.
526 */
527 static void help_to_text(const char *zHelp, Blob *pText){
528 int i, x;
529 char c;
530 if( zHelp[0]=='>' ){
531 blob_appendf(pText, "Usage:");
532 zHelp++;
533 }
534 for(i=0; (c = zHelp[i])!=0; i++){
535 if( c=='%' && strncmp(zHelp+i,"%fossil",7)==0 ){
536 if( i>0 ) blob_append(pText, zHelp, i);
537 blob_append(pText, "fossil", 6);
538 zHelp += i+7;
@@ -1059,10 +1063,80 @@
1063 }
1064 @ </dl>
1065 blob_reset(&buf);
1066 style_finish_page();
1067 }
1068
1069 /*
1070 ** Input z[] is help text for zTopic. If zTopic has sub-command zSub,
1071 ** then cut out all portions of the original help text that do not
1072 ** directly pertain to zSub and write the zSub-relevant parts into
1073 ** pOut.
1074 **
1075 ** Return the number of lines of z[] written into pOut. A return of
1076 ** zero means no simplification occurred.
1077 */
1078 static int simplify_to_subtopic(
1079 const char *z, /* Full original help text */
1080 Blob *pOut, /* Write simplified help text here */
1081 const char *zTopic, /* TOPIC */
1082 const char *zSubtopic /* SUBTOPIC */
1083 ){
1084 Blob in, line;
1085 int n = 0;
1086 char *zGlob = mprintf("> fossil %s *%s*", zTopic, zSubtopic);
1087
1088 blob_init(&in, z, -1);
1089 while( blob_line(&in, &line) ){
1090 if( sqlite3_strglob(zGlob, blob_str(&line))==0 ){
1091 blob_appendb(pOut, &line);
1092 n++;
1093 while( blob_line(&in, &line) && blob_str(&line)[0]!='>' ){
1094 blob_appendb(pOut, &line);
1095 n++;
1096 }
1097 break;
1098 }
1099 }
1100 fossil_free(zGlob);
1101 if( n ) blob_trim(pOut);
1102 return n;
1103 return 0;
1104 }
1105
1106 /*
1107 ** Input z[] is help text for a command zTopic. Write into pOut all lines of
1108 ** z[] that show the command-line syntax for that command. Lines written
1109 ** to pOut are lines that begin with out of:
1110 **
1111 ** Usage:
1112 ** or:
1113 ** > fossil TOPIC
1114 **
1115 ** Return the number of lines written into pOut.
1116 */
1117 static int simplify_to_usage(
1118 const char *z, /* Full original help text */
1119 Blob *pOut, /* Write simplified help text here */
1120 const char *zTopic /* The command for which z[] is full help text */
1121 ){
1122 ReCompiled *pRe = 0;
1123 Blob in, line;
1124 int n = 0;
1125
1126 re_compile(&pRe, "^(Usage: | *[Oo]r: +%fossi |> fossil )", 0);
1127 blob_init(&in, z, -1);
1128 while( blob_line(&in, &line) ){
1129 if( re_match(pRe, (unsigned char*)blob_str(&line), blob_strlen(&line)) ){
1130 blob_appendb(pOut, &line);
1131 n++;
1132 }
1133 }
1134 re_free(pRe);
1135 if( n ) blob_trim(pOut);
1136 return n;
1137 }
1138
1139 static void multi_column_list(const char **azWord, int nWord){
1140 int i, j, len;
1141 int mxLen = 0;
1142 int nCol;
@@ -1147,54 +1221,75 @@
1221 @ --systemtrace Trace calls to system()
1222 @ -U|--user USER Make the default user be USER
1223 @ --utc Display times using UTC
1224 @ --vfs NAME Cause SQLite to use the NAME VFS
1225 ;
1226
1227 /*
1228 ** COMMAND: usage
1229 **
1230 ** Usage: %fossil usage COMMAND [SUBCOMMAND]
1231 **
1232 ** Show succinct usage instruction for a Fossil command. Shorthand
1233 ** for "fossil help --usage COMMAND [SUBCOMMAND]"
1234 */
1235 void usage_cmd(void){
1236 help_cmd();
1237 }
1238
1239 /*
1240 ** COMMAND: help
1241 **
1242 ** Usage: %fossil help [OPTIONS] [TOPIC] [SUBCOMMAND]
1243 **
1244 ** Display information on how to use TOPIC, which may be a command, webpage, or
1245 ** setting. Webpage names begin with "/". If TOPIC is omitted, a list of
1246 ** topics is returned.
1247 **
1248 ** The following options can be used when TOPIC is omitted:
1249 **
1250 ** -a|--all List both common and auxiliary commands
1251 ** -e|--everything List all help on all topics
1252 ** -f|--full List full set of commands (including auxiliary
1253 ** and unsupported "test" commands), options,
1254 ** settings, and web pages
1255 ** -o|--options List command-line options common to all commands
1256 ** -s|--setting List setting names
1257 ** -t|--test List unsupported "test" commands
1258 ** -v|--verbose List both names and help text
1259 ** -x|--aux List only auxiliary commands
1260 ** -w|--www List all web pages
 
 
 
 
1261 **
1262 ** These options can be used when TOPIC is present:
1263 **
 
1264 ** -c|--commands Restrict TOPIC search to commands
1265 ** -h|--html Format output as HTML rather than plain text
1266 ** --raw Output raw, unformatted help text
1267 ** -u|--usage Show a succinct usage summary, not full help text
1268 */
1269 void help_cmd(void){
1270 int rc;
1271 int mask = CMDFLAG_ANY; /* Mask of help topic types */
1272 int isPage = 0; /* True if TOPIC is a page */
1273 int verboseFlag = 0; /* -v option */
1274 int commandsFlag = 0; /* -c option */
1275 const char *z; /* Original, untranslated help text */
1276 const char *zCmdOrPage; /* "command" or "page" or "setting" */
1277 const CmdOrPage *pCmd = 0; /* ptr to aCommand[] entry for TOPIC */
1278 int useHtml = 0; /* -h option */
1279 int bUsage = g.zCmdName[0]=='u'; /* --usage or "fossil usage TOPIC" */
1280 int bRaw; /* --raw option */
1281 const char *zTopic; /* TOPIC argument */
1282 const char *zSubtopic = 0; /* SUBTOPIC argument */
1283 Blob subtext1, subtext2; /* Subsets of z[] containing subtopic/usage */
1284 Blob txt; /* Text after rendering */
1285
1286 verboseFlag = find_option("verbose","v",0)!=0;
1287 commandsFlag = find_option("commands","c",0)!=0;
1288 useHtml = find_option("html","h",0)!=0;
1289 bRaw = find_option("raw",0,0)!=0;
1290 if( find_option("usage","u",0)!=0 ) bUsage = 1;
1291 if( find_option("options","o",0) ){
1292 fossil_print("%s", zOptions);
1293 return;
1294 }
1295 else if( find_option("all","a",0) ){
@@ -1249,10 +1344,11 @@
1344 command_list(CMDFLAG_1ST_TIER,verboseFlag,useHtml);
1345 if( !verboseFlag ) version_cmd();
1346 return;
1347 }
1348 zTopic = g.argv[2];
1349 zSubtopic = g.argc>=4 ? g.argv[3] : 0;
1350 isPage = ('/' == zTopic[0]) ? 1 : 0;
1351 if(isPage){
1352 zCmdOrPage = "page";
1353 }else if( commandsFlag ){
1354 mask = CMDFLAG_COMMAND;
@@ -1273,23 +1369,38 @@
1369 fossil_print("Did you mean one of these TOPICs:\n");
1370 n = dispatch_approx_match(g.argv[2], 5, az);
1371 for(i=0; i<n; i++){
1372 fossil_print(" * %s\n", az[i]);
1373 }
1374 fossil_print("Other commands to try:\n");
1375 fossil_print(" fossil search -h PATTERN ;# search all help text\n");
1376 fossil_print(" fossil help -a ;# show all commands\n");
1377 fossil_print(" fossil help -w ;# show all web-pages\n");
1378 fossil_print(" fossil help -s ;# show all settings\n");
1379 fossil_print(" fossil help -o ;# show global options\n");
1380 return;
1381 }
1382 blob_init(&subtext1, 0, 0);
1383 blob_init(&subtext2, 0, 0);
1384 z = pCmd->zHelp;
1385 if( z==0 ){
1386 fossil_fatal("no help available for the %s %s",
1387 pCmd->zName, zCmdOrPage);
1388 }
1389 if( zSubtopic!=0 ){
1390 if( simplify_to_subtopic(z, &subtext1, zTopic, zSubtopic) ){
1391 z = blob_str(&subtext1);
1392 }else{
1393 fossil_print("No subtopic \"%s\" for \"%s\".\n", zTopic, zSubtopic);
1394 if( strstr(z, "Usage:")!=0 || strstr(z, "\n> fossil")!=0 ){
1395 bUsage = 1;
1396 }
1397 }
1398 }
1399 if( bUsage && simplify_to_usage(z, &subtext2, zTopic) ){
1400 z = blob_str(&subtext2);
1401 }
1402 if( pCmd->eCmdFlags & CMDFLAG_SETTING ){
1403 const Setting *pSetting = db_find_setting(pCmd->zName, 0);
1404 char *zDflt = 0;
1405 if( pSetting!=0 && pSetting->def!=0 && *pSetting->def!=0 ){
1406 zDflt = mprintf(" (default: %s)", pSetting->def);
@@ -1299,17 +1410,21 @@
1410 (pCmd->eCmdFlags & CMDFLAG_VERSIONABLE)!=0 ? " (versionable)" : ""
1411 );
1412 fossil_free(zDflt);
1413 }
1414 blob_init(&txt, 0, 0);
1415 if( bRaw ){
1416 blob_append(&txt, z, -1);
1417 }else if( useHtml ){
1418 help_to_html(z, &txt);
1419 }else{
1420 help_to_text(z, &txt);
1421 }
1422 fossil_print("%s\n", blob_str(&txt));
1423 blob_reset(&txt);
1424 blob_reset(&subtext1);
1425 blob_reset(&subtext2);
1426 }
1427
1428 /*
1429 ** Return a pointer to the setting information array.
1430 **
1431

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button