| | @@ -54,10 +54,11 @@ |
| 54 | 54 | /* NOTE: 0x0400 = CMDFLAG_SENSITIVE in mkindex.c! */ |
| 55 | 55 | #define CMDFLAG_HIDDEN 0x0800 /* Elide from most listings */ |
| 56 | 56 | #define CMDFLAG_LDAVG_EXEMPT 0x1000 /* Exempt from load_control() */ |
| 57 | 57 | #define CMDFLAG_ALIAS 0x2000 /* Command aliases */ |
| 58 | 58 | #define CMDFLAG_KEEPEMPTY 0x4000 /* Do not unset empty settings */ |
| 59 | +#define CMDFLAG_ABBREVSUBCMD 0x8000 /* Help text abbreviates subcommands */ |
| 59 | 60 | /**************************************************************************/ |
| 60 | 61 | |
| 61 | 62 | /* Values for the 2nd parameter to dispatch_name_search() */ |
| 62 | 63 | #define CMDFLAG_ANY 0x0038 /* Match anything */ |
| 63 | 64 | #define CMDFLAG_PREFIX 0x0200 /* Prefix match is ok */ |
| | @@ -522,14 +523,14 @@ |
| 522 | 523 | } |
| 523 | 524 | |
| 524 | 525 | /* |
| 525 | 526 | ** Format help text for TTY display. |
| 526 | 527 | */ |
| 527 | | -static void help_to_text(const char *zHelp, Blob *pText){ |
| 528 | +static void help_to_text(const char *zHelp, Blob *pText, int bUsage){ |
| 528 | 529 | int i, x; |
| 529 | 530 | char c; |
| 530 | | - if( zHelp[0]=='>' ){ |
| 531 | + if( !bUsage && zHelp[0]=='>' ){ |
| 531 | 532 | blob_appendf(pText, "Usage:"); |
| 532 | 533 | zHelp++; |
| 533 | 534 | } |
| 534 | 535 | for(i=0; (c = zHelp[i])!=0; i++){ |
| 535 | 536 | if( c=='%' && strncmp(zHelp+i,"%fossil",7)==0 ){ |
| | @@ -607,11 +608,11 @@ |
| 607 | 608 | fossil_print("# %s\n", aCommand[bktHelp[aCommand[i].iHelp][j]].zName); |
| 608 | 609 | fossil_print("%s\n\n", aCommand[i].zHelp); |
| 609 | 610 | }else{ |
| 610 | 611 | Blob txt; |
| 611 | 612 | blob_init(&txt, 0, 0); |
| 612 | | - help_to_text(aCommand[i].zHelp, &txt); |
| 613 | + help_to_text(aCommand[i].zHelp, &txt, 0); |
| 613 | 614 | for(j=0; j<occHelp[aCommand[i].iHelp]; j++){ |
| 614 | 615 | fossil_print("# %s%s\n", |
| 615 | 616 | aCommand[bktHelp[aCommand[i].iHelp][j]].zName, |
| 616 | 617 | (aCommand[i].eCmdFlags & CMDFLAG_VERSIONABLE)!=0 ? |
| 617 | 618 | " (versionable)" : ""); |
| | @@ -859,11 +860,11 @@ |
| 859 | 860 | if( pCmd->zHelp[0]==0 ){ |
| 860 | 861 | @ No help available for "%h(pCmd->zName)" |
| 861 | 862 | }else if( P("plaintext") ){ |
| 862 | 863 | Blob txt; |
| 863 | 864 | blob_init(&txt, 0, 0); |
| 864 | | - help_to_text(pCmd->zHelp, &txt); |
| 865 | + help_to_text(pCmd->zHelp, &txt, 0); |
| 865 | 866 | @ <pre class="helpPage"> |
| 866 | 867 | @ %h(blob_str(&txt)) |
| 867 | 868 | @ </pre> |
| 868 | 869 | blob_reset(&txt); |
| 869 | 870 | }else if( P("raw") ){ |
| | @@ -1063,10 +1064,28 @@ |
| 1063 | 1064 | } |
| 1064 | 1065 | @ </dl> |
| 1065 | 1066 | blob_reset(&buf); |
| 1066 | 1067 | style_finish_page(); |
| 1067 | 1068 | } |
| 1069 | + |
| 1070 | +/* |
| 1071 | +** Return true if p is the first line paste the end of |
| 1072 | +** the previous subcommand. |
| 1073 | +*/ |
| 1074 | +static int is_subcommand_end(Blob *p, int bAbbrevSubcmd, ReCompiled *pRe){ |
| 1075 | + if( bAbbrevSubcmd ){ |
| 1076 | + int i; |
| 1077 | + if( re_match(pRe, (unsigned char*)blob_buffer(p), blob_strlen(p)) ){ |
| 1078 | + return 0; |
| 1079 | + } |
| 1080 | + if( blob_size(p)<4 ) return 1; |
| 1081 | + for(i=0; i<4 && blob_buffer(p)[i]==' '; i++){} |
| 1082 | + return i<4; |
| 1083 | + }else{ |
| 1084 | + return blob_buffer(p)[0]=='>'; |
| 1085 | + } |
| 1086 | +} |
| 1068 | 1087 | |
| 1069 | 1088 | /* |
| 1070 | 1089 | ** Input z[] is help text for zTopic. If zTopic has sub-command zSub, |
| 1071 | 1090 | ** then cut out all portions of the original help text that do not |
| 1072 | 1091 | ** directly pertain to zSub and write the zSub-relevant parts into |
| | @@ -1077,33 +1096,41 @@ |
| 1077 | 1096 | */ |
| 1078 | 1097 | static int simplify_to_subtopic( |
| 1079 | 1098 | const char *z, /* Full original help text */ |
| 1080 | 1099 | Blob *pOut, /* Write simplified help text here */ |
| 1081 | 1100 | const char *zTopic, /* TOPIC */ |
| 1082 | | - const char *zSubtopic /* SUBTOPIC */ |
| 1101 | + const char *zSubtopic, /* SUBTOPIC */ |
| 1102 | + int bAbbrevSubcmd /* True if z[] contains abbreviated subcommands */ |
| 1083 | 1103 | ){ |
| 1084 | 1104 | Blob in, line; //, subsection; |
| 1085 | 1105 | int n = 0; |
| 1086 | 1106 | char *zQTop = re_quote(zTopic); |
| 1087 | 1107 | char *zQSub = re_quote(zSubtopic); |
| 1088 | | - char *zPattern = mprintf("> fossil %s .*\\b%s\\b", zQTop, zQSub); |
| 1108 | + char *zPattern; |
| 1089 | 1109 | ReCompiled *pRe = 0; |
| 1090 | 1110 | |
| 1111 | + if( bAbbrevSubcmd ){ |
| 1112 | + zPattern = mprintf(" ([a-z]+ ?\\| ?)*%s\\b", zQSub); |
| 1113 | + }else{ |
| 1114 | + zPattern = mprintf("> ?fossil %s .*\\b%s\\b", zQTop, zQSub); |
| 1115 | + } |
| 1091 | 1116 | fossil_free(zQTop); |
| 1092 | 1117 | fossil_free(zQSub); |
| 1093 | 1118 | re_compile(&pRe, zPattern, 0); |
| 1094 | 1119 | fossil_free(zPattern); |
| 1095 | 1120 | blob_init(&in, z, -1); |
| 1096 | 1121 | while( blob_line(&in, &line) ){ |
| 1097 | 1122 | if( re_match(pRe, (unsigned char*)blob_buffer(&line), blob_strlen(&line)) ){ |
| 1098 | 1123 | blob_appendb(pOut, &line); |
| 1099 | 1124 | n++; |
| 1100 | | - while( blob_line(&in, &line) && blob_buffer(&line)[0]!='>' ){ |
| 1125 | + while( blob_line(&in, &line) |
| 1126 | + && !is_subcommand_end(&line,bAbbrevSubcmd,pRe) |
| 1127 | + ){ |
| 1101 | 1128 | blob_appendb(pOut, &line); |
| 1102 | 1129 | n++; |
| 1103 | 1130 | } |
| 1104 | | - break; |
| 1131 | + if( !bAbbrevSubcmd ) break; |
| 1105 | 1132 | } |
| 1106 | 1133 | } |
| 1107 | 1134 | blob_reset(&line); |
| 1108 | 1135 | re_free(pRe); |
| 1109 | 1136 | if( n ){ |
| | @@ -1110,10 +1137,43 @@ |
| 1110 | 1137 | blob_trim(pOut); |
| 1111 | 1138 | blob_reset(&in); |
| 1112 | 1139 | } |
| 1113 | 1140 | return n; |
| 1114 | 1141 | } |
| 1142 | + |
| 1143 | +/* |
| 1144 | +** Input p is a "Usage:" line or a subcommand line. Simplify this line |
| 1145 | +** for the --usage option and write it into pOut. |
| 1146 | +*/ |
| 1147 | +static void simplify_usage_line( |
| 1148 | + Blob *p, |
| 1149 | + Blob *pOut, |
| 1150 | + int bAbbrevSubcmd, |
| 1151 | + const char *zCmd |
| 1152 | +){ |
| 1153 | + const char *z = blob_buffer(p); |
| 1154 | + int sz = blob_size(p); |
| 1155 | + int i = 0; |
| 1156 | + if( sz>6 && z[0]=='U' ){ |
| 1157 | + for(i=1; i<sz && !fossil_isspace(z[i]); i++){} |
| 1158 | + }else if( sz>0 && z[0]=='>' ){ |
| 1159 | + i = 1; |
| 1160 | + }else if( sz>4 && bAbbrevSubcmd |
| 1161 | + && memcmp(z," ",3)==0 && !fossil_isspace(z[3]) ){ |
| 1162 | + int j; |
| 1163 | + for(j=3; j<sz-1 && (z[j]!=' ' || z[j+1]!=' '); j++){} |
| 1164 | + blob_appendf(pOut, "fossil %s %.*s\n", zCmd, j-3, &z[3]); |
| 1165 | + return; |
| 1166 | + }else{ |
| 1167 | + while( i<sz && fossil_isspace(z[i]) ) i++; |
| 1168 | + if( i+2<sz && (z[i]=='o' || z[i]=='O') && z[i+1]=='r' ){ |
| 1169 | + while( i<sz && !fossil_isspace(z[i]) ) i++; |
| 1170 | + } |
| 1171 | + } |
| 1172 | + while( i<sz && fossil_isspace(z[i]) ) i++; |
| 1173 | + blob_append(pOut, &z[i], sz-i); |
| 1174 | +} |
| 1115 | 1175 | |
| 1116 | 1176 | /* |
| 1117 | 1177 | ** Input z[] is help text for a command zTopic. Write into pOut all lines of |
| 1118 | 1178 | ** z[] that show the command-line syntax for that command. Lines written |
| 1119 | 1179 | ** to pOut are lines that begin with out of: |
| | @@ -1125,21 +1185,26 @@ |
| 1125 | 1185 | ** Return the number of lines written into pOut. |
| 1126 | 1186 | */ |
| 1127 | 1187 | static int simplify_to_usage( |
| 1128 | 1188 | const char *z, /* Full original help text */ |
| 1129 | 1189 | Blob *pOut, /* Write simplified help text here */ |
| 1130 | | - const char *zTopic /* The command for which z[] is full help text */ |
| 1190 | + const char *zTopic, /* The command for which z[] is full help text */ |
| 1191 | + int bAbbrevSubcmd /* z[] uses abbreviated subcommands */ |
| 1131 | 1192 | ){ |
| 1132 | 1193 | ReCompiled *pRe = 0; |
| 1133 | 1194 | Blob in, line; |
| 1134 | 1195 | int n = 0; |
| 1135 | 1196 | |
| 1136 | | - re_compile(&pRe, "^(Usage: | *[Oo]r: +%fossi |> fossil )", 0); |
| 1197 | + if( bAbbrevSubcmd ){ |
| 1198 | + re_compile(&pRe, "^(Usage: | [a-z][-a-z|]+ .*)", 0); |
| 1199 | + }else{ |
| 1200 | + re_compile(&pRe, "^(Usage: | *[Oo]r: +%fossi |> ?fossil )", 0); |
| 1201 | + } |
| 1137 | 1202 | blob_init(&in, z, -1); |
| 1138 | 1203 | while( blob_line(&in, &line) ){ |
| 1139 | 1204 | if( re_match(pRe, (unsigned char*)blob_buffer(&line), blob_strlen(&line)) ){ |
| 1140 | | - blob_appendb(pOut, &line); |
| 1205 | + simplify_usage_line(&line, pOut, bAbbrevSubcmd, zTopic); |
| 1141 | 1206 | n++; |
| 1142 | 1207 | } |
| 1143 | 1208 | } |
| 1144 | 1209 | re_free(pRe); |
| 1145 | 1210 | if( n ) blob_trim(pOut); |
| | @@ -1150,29 +1215,44 @@ |
| 1150 | 1215 | ** Input z[] is help text. Write into pOut all lines of z[] that show |
| 1151 | 1216 | ** command-line options. Return the number of lines written. |
| 1152 | 1217 | */ |
| 1153 | 1218 | static int simplify_to_options( |
| 1154 | 1219 | const char *z, /* Full original help text */ |
| 1155 | | - Blob *pOut /* Write simplified help text here */ |
| 1220 | + Blob *pOut, /* Write simplified help text here */ |
| 1221 | + int bAbbrevSubcmd, /* z[] uses abbreviated subcommands */ |
| 1222 | + const char *zCmd /* Name of the command that z[] describes */ |
| 1156 | 1223 | ){ |
| 1157 | 1224 | ReCompiled *pRe = 0; |
| 1158 | 1225 | Blob txt, line, subsection; |
| 1159 | 1226 | int n = 0; |
| 1227 | + int bSubsectionSeen = 0; |
| 1160 | 1228 | |
| 1161 | 1229 | blob_init(&txt, z, -1); |
| 1162 | 1230 | blob_init(&subsection, 0, 0); |
| 1163 | 1231 | re_compile(&pRe, "^ +-.* ", 0); |
| 1164 | 1232 | while( blob_line(&txt, &line) ){ |
| 1165 | | - size_t len = blob_strlen(&line); |
| 1166 | | - if( re_match(pRe, (unsigned char*)blob_buffer(&line), (int)len) ){ |
| 1167 | | - if( blob_strlen(&subsection) && blob_buffer(&line)[0]!='>' ){ |
| 1168 | | - blob_appendb(pOut, &subsection); |
| 1233 | + int len = blob_size(&line); |
| 1234 | + unsigned char *zLine = (unsigned char *)blob_buffer(&line); |
| 1235 | + if( re_match(pRe, zLine, len) ){ |
| 1236 | + if( blob_size(&subsection) ){ |
| 1237 | + simplify_usage_line(&subsection, pOut, bAbbrevSubcmd, zCmd); |
| 1169 | 1238 | blob_reset(&subsection); |
| 1170 | 1239 | } |
| 1171 | 1240 | blob_appendb(pOut, &line); |
| 1172 | | - }else if( len>9 && strncmp(blob_buffer(&line),"> fossil ",9)==0 ){ |
| 1241 | + }else if( len>7 && !fossil_isspace(zLine[0]) && bSubsectionSeen |
| 1242 | + && sqlite3_strlike("%options:%",blob_str(&line),0)==0 ){ |
| 1243 | + subsection = line; |
| 1244 | + }else if( !bAbbrevSubcmd && len>9 |
| 1245 | + && (memcmp(zLine,"> fossil ",9)==0 || memcmp(zLine,"> fossil",9)) ){ |
| 1246 | + subsection = line; |
| 1247 | + bSubsectionSeen = 1; |
| 1248 | + }else if( bAbbrevSubcmd && len>5 && memcmp(zLine," ",3)==0 |
| 1249 | + && fossil_isalpha(zLine[3]) ){ |
| 1173 | 1250 | subsection = line; |
| 1251 | + bSubsectionSeen = 1; |
| 1252 | + }else if( len>1 && !fossil_isspace(zLine[0]) && bSubsectionSeen ){ |
| 1253 | + blob_reset(&subsection); |
| 1174 | 1254 | } |
| 1175 | 1255 | } |
| 1176 | 1256 | re_free(pRe); |
| 1177 | 1257 | blob_trim(pOut); |
| 1178 | 1258 | blob_reset(&subsection); |
| | @@ -1286,10 +1366,12 @@ |
| 1286 | 1366 | ** See also: [[help]], [[usage]] |
| 1287 | 1367 | */ |
| 1288 | 1368 | void options_cmd(void){ |
| 1289 | 1369 | Blob s1, s2, out; |
| 1290 | 1370 | const char *z; |
| 1371 | + const char *zTopic; |
| 1372 | + int bAbbrevSubcmd = 0; |
| 1291 | 1373 | |
| 1292 | 1374 | verify_all_options(); |
| 1293 | 1375 | if( g.argc>4 ){ |
| 1294 | 1376 | usage("[COMMAND] [SUBCOMMAND]"); |
| 1295 | 1377 | } |
| | @@ -1297,13 +1379,13 @@ |
| 1297 | 1379 | if( g.argc==2 ){ |
| 1298 | 1380 | fossil_print("%s", zOptions); |
| 1299 | 1381 | return; |
| 1300 | 1382 | }else{ |
| 1301 | 1383 | int rc; |
| 1302 | | - const char *zTopic = g.argv[2]; |
| 1303 | 1384 | const char *zSubtopic = g.argc==4 ? g.argv[3] : 0; |
| 1304 | 1385 | const CmdOrPage *pCmd = 0; |
| 1386 | + zTopic = g.argv[2]; |
| 1305 | 1387 | rc = dispatch_name_search(zTopic, CMDFLAG_COMMAND|CMDFLAG_PREFIX, &pCmd); |
| 1306 | 1388 | if( rc ){ |
| 1307 | 1389 | if( rc==1 ){ |
| 1308 | 1390 | fossil_print("unknown command: %s\n", zTopic); |
| 1309 | 1391 | }else{ |
| | @@ -1313,22 +1395,23 @@ |
| 1313 | 1395 | } |
| 1314 | 1396 | z = pCmd->zHelp; |
| 1315 | 1397 | if( z==0 ){ |
| 1316 | 1398 | fossil_fatal("no help available for the %s", pCmd->zName); |
| 1317 | 1399 | } |
| 1400 | + bAbbrevSubcmd = (pCmd->eCmdFlags & CMDFLAG_ABBREVSUBCMD)!=0; |
| 1318 | 1401 | if( zSubtopic ){ |
| 1319 | | - if( simplify_to_subtopic(z, &s1, zTopic, zSubtopic) ){ |
| 1402 | + if( simplify_to_subtopic(z, &s1, zTopic, zSubtopic, bAbbrevSubcmd) ){ |
| 1320 | 1403 | z = blob_str(&s1); |
| 1321 | 1404 | }else{ |
| 1322 | 1405 | fossil_print("No subcommand \"%s\" for \"%s\".\n", zSubtopic, zTopic); |
| 1323 | 1406 | } |
| 1324 | 1407 | } |
| 1325 | 1408 | } |
| 1326 | 1409 | blob_init(&s2, 0, 0); |
| 1327 | | - simplify_to_options(z, &s2); |
| 1410 | + simplify_to_options(z, &s2, bAbbrevSubcmd, zTopic); |
| 1328 | 1411 | blob_init(&out, 0, 0); |
| 1329 | | - help_to_text(blob_str(&s2), &out); |
| 1412 | + help_to_text(blob_str(&s2), &out, 1); |
| 1330 | 1413 | fossil_print("%s\n", blob_str(&out)); |
| 1331 | 1414 | blob_reset(&out); |
| 1332 | 1415 | blob_reset(&s1); |
| 1333 | 1416 | blob_reset(&s2); |
| 1334 | 1417 | } |
| | @@ -1347,10 +1430,11 @@ |
| 1347 | 1430 | const char *zTopic; |
| 1348 | 1431 | const char *zSubtopic; |
| 1349 | 1432 | const CmdOrPage *pCmd = 0; |
| 1350 | 1433 | Blob s1, s2, out; |
| 1351 | 1434 | const char *z; |
| 1435 | + int bAbbrevSubcmd = 0; |
| 1352 | 1436 | |
| 1353 | 1437 | verify_all_options(); |
| 1354 | 1438 | if( g.argc<3 || g.argc>4 ){ |
| 1355 | 1439 | usage("COMMAND [SUBCOMMAND]"); |
| 1356 | 1440 | } |
| | @@ -1370,28 +1454,29 @@ |
| 1370 | 1454 | for(i=0; i<n; i++){ |
| 1371 | 1455 | fossil_print(" * %s\n", az[i]); |
| 1372 | 1456 | } |
| 1373 | 1457 | return; |
| 1374 | 1458 | } |
| 1459 | + bAbbrevSubcmd = (pCmd->eCmdFlags & CMDFLAG_ABBREVSUBCMD)!=0; |
| 1375 | 1460 | z = pCmd->zHelp; |
| 1376 | 1461 | if( z==0 ){ |
| 1377 | 1462 | fossil_fatal("no help available for the %s", pCmd->zName); |
| 1378 | 1463 | } |
| 1379 | 1464 | blob_init(&s1, 0, 0); |
| 1380 | 1465 | blob_init(&s2, 0, 0); |
| 1381 | 1466 | if( zSubtopic!=0 ){ |
| 1382 | | - if( simplify_to_subtopic(z, &s1, zTopic, zSubtopic) ){ |
| 1467 | + if( simplify_to_subtopic(z, &s1, zTopic, zSubtopic, bAbbrevSubcmd) ){ |
| 1383 | 1468 | z = blob_str(&s1); |
| 1384 | 1469 | }else{ |
| 1385 | 1470 | fossil_print("No subcommand \"%s\" for \"%s\".\n", zSubtopic, zTopic); |
| 1386 | 1471 | } |
| 1387 | 1472 | } |
| 1388 | | - if( simplify_to_usage(z, &s2, zTopic) ){ |
| 1473 | + if( simplify_to_usage(z, &s2, zTopic, bAbbrevSubcmd) ){ |
| 1389 | 1474 | z = blob_str(&s2); |
| 1390 | 1475 | } |
| 1391 | 1476 | blob_init(&out, 0, 0); |
| 1392 | | - help_to_text(z, &out); |
| 1477 | + help_to_text(z, &out, 1); |
| 1393 | 1478 | fossil_print("%s\n", blob_str(&out)); |
| 1394 | 1479 | blob_reset(&out); |
| 1395 | 1480 | blob_reset(&s1); |
| 1396 | 1481 | blob_reset(&s2); |
| 1397 | 1482 | } |
| | @@ -1446,10 +1531,11 @@ |
| 1446 | 1531 | int bOptions; /* --options */ |
| 1447 | 1532 | const char *zTopic; /* TOPIC argument */ |
| 1448 | 1533 | const char *zSubtopic = 0; /* SUBTOPIC argument */ |
| 1449 | 1534 | Blob subtext1, subtext2, s3; /* Subsets of z[] containing subtopic/usage */ |
| 1450 | 1535 | Blob txt; /* Text after rendering */ |
| 1536 | + int bAbbrevSubcmd = 0; /* Help text uses abbreviated subcommands */ |
| 1451 | 1537 | |
| 1452 | 1538 | verboseFlag = find_option("verbose","v",0)!=0; |
| 1453 | 1539 | commandsFlag = find_option("commands","c",0)!=0; |
| 1454 | 1540 | useHtml = find_option("html","h",0)!=0; |
| 1455 | 1541 | bRaw = find_option("raw",0,0)!=0; |
| | @@ -1548,33 +1634,38 @@ |
| 1548 | 1634 | fossil_print(" fossil help -w ;# show all web-pages\n"); |
| 1549 | 1635 | fossil_print(" fossil help -s ;# show all settings\n"); |
| 1550 | 1636 | fossil_print(" fossil help -o ;# show global options\n"); |
| 1551 | 1637 | return; |
| 1552 | 1638 | } |
| 1639 | + bAbbrevSubcmd = (pCmd->eCmdFlags & CMDFLAG_ABBREVSUBCMD)!=0; |
| 1553 | 1640 | z = pCmd->zHelp; |
| 1554 | 1641 | if( z==0 ){ |
| 1555 | 1642 | fossil_fatal("no help available for the %s %s", |
| 1556 | 1643 | pCmd->zName, zCmdOrPage); |
| 1557 | 1644 | } |
| 1558 | 1645 | blob_init(&subtext1, 0, 0); |
| 1559 | 1646 | blob_init(&subtext2, 0, 0); |
| 1560 | 1647 | blob_init(&s3, 0, 0); |
| 1561 | 1648 | if( zSubtopic!=0 ){ |
| 1562 | | - if( simplify_to_subtopic(z, &subtext1, zTopic, zSubtopic) ){ |
| 1649 | + if( simplify_to_subtopic(z, &subtext1, zTopic, zSubtopic, bAbbrevSubcmd) ){ |
| 1563 | 1650 | z = blob_str(&subtext1); |
| 1564 | 1651 | }else{ |
| 1565 | 1652 | fossil_print("No subtopic \"%s\" for \"%s\".\n", zTopic, zSubtopic); |
| 1566 | | - if( strstr(z, "Usage:")!=0 || strstr(z, "\n> fossil")!=0 ){ |
| 1653 | + if( strstr(z, "Usage:")!=0 || strstr(z, "\n> ?fossil")!=0 ){ |
| 1567 | 1654 | bUsage = 1; |
| 1568 | 1655 | } |
| 1569 | 1656 | } |
| 1570 | 1657 | } |
| 1571 | | - if( bUsage && simplify_to_usage(z, &subtext2, zTopic) ){ |
| 1572 | | - z = blob_str(&subtext2); |
| 1658 | + if( bUsage ){ |
| 1659 | + if( simplify_to_usage(z, &subtext2, zTopic, bAbbrevSubcmd) ){ |
| 1660 | + z = blob_str(&subtext2); |
| 1661 | + }else{ |
| 1662 | + bUsage = 0; |
| 1663 | + } |
| 1573 | 1664 | } |
| 1574 | 1665 | if( bOptions ){ |
| 1575 | | - simplify_to_options(z, &s3); |
| 1666 | + simplify_to_options(z, &s3, bAbbrevSubcmd, zTopic); |
| 1576 | 1667 | z = blob_str(&s3); |
| 1577 | 1668 | } |
| 1578 | 1669 | if( pCmd && pCmd->eCmdFlags & CMDFLAG_SETTING ){ |
| 1579 | 1670 | const Setting *pSetting = db_find_setting(pCmd->zName, 0); |
| 1580 | 1671 | char *zDflt = 0; |
| | @@ -1591,13 +1682,13 @@ |
| 1591 | 1682 | if( bRaw ){ |
| 1592 | 1683 | blob_append(&txt, z, -1); |
| 1593 | 1684 | }else if( useHtml ){ |
| 1594 | 1685 | help_to_html(z, &txt); |
| 1595 | 1686 | }else{ |
| 1596 | | - help_to_text(z, &txt); |
| 1687 | + help_to_text(z, &txt, bUsage); |
| 1597 | 1688 | } |
| 1598 | | - fossil_print("%s\n", blob_str(&txt)); |
| 1689 | + if( blob_strlen(&txt)>0 ) fossil_print("%s\n", blob_str(&txt)); |
| 1599 | 1690 | blob_reset(&txt); |
| 1600 | 1691 | blob_reset(&subtext1); |
| 1601 | 1692 | blob_reset(&subtext2); |
| 1602 | 1693 | } |
| 1603 | 1694 | |
| | @@ -1772,11 +1863,11 @@ |
| 1772 | 1863 | sqlite3_result_text(ctx, pPage->zHelp, -1, SQLITE_STATIC); |
| 1773 | 1864 | break; |
| 1774 | 1865 | case 4: { /* formatted */ |
| 1775 | 1866 | Blob txt; |
| 1776 | 1867 | blob_init(&txt, 0, 0); |
| 1777 | | - help_to_text(pPage->zHelp, &txt); |
| 1868 | + help_to_text(pPage->zHelp, &txt, 0); |
| 1778 | 1869 | sqlite3_result_text(ctx, blob_str(&txt), -1, fossil_free); |
| 1779 | 1870 | break; |
| 1780 | 1871 | } |
| 1781 | 1872 | case 5: { /* formatted */ |
| 1782 | 1873 | Blob txt; |
| 1783 | 1874 | |