Fossil SCM

Remove the "fossil usage" and "fossil options" command. Use instead the the --usage/-u or --options/-o options on the "fossil help" command. Other improvements and fixes to the recent "fossil help" enhancement.

drh 2025-03-01 20:31 trunk
Commit b097e6899e6dc0c97dce181dec2e4093789a780c1cff750f233061fb830975aa
2 files changed +57 -161 +2
+57 -161
--- src/dispatch.c
+++ src/dispatch.c
@@ -526,12 +526,16 @@
526526
** Format help text for TTY display.
527527
*/
528528
static void help_to_text(const char *zHelp, Blob *pText, int bUsage){
529529
int i, x;
530530
char c;
531
- if( !bUsage && zHelp[0]=='>' ){
532
- blob_appendf(pText, "Usage:");
531
+ if( zHelp[0]=='>' ){
532
+ if( !bUsage ){
533
+ blob_appendf(pText, "Usage:");
534
+ }else{
535
+ blob_append_char(pText, ' ');
536
+ }
533537
zHelp++;
534538
}
535539
for(i=0; (c = zHelp[i])!=0; i++){
536540
if( c=='%' && strncmp(zHelp+i,"%fossil",7)==0 ){
537541
if( i>0 ) blob_append(pText, zHelp, i);
@@ -1066,24 +1070,31 @@
10661070
blob_reset(&buf);
10671071
style_finish_page();
10681072
}
10691073
10701074
/*
1071
-** Return true if p is the first line paste the end of
1072
-** the previous subcommand.
1075
+** Analyze p and return one of three values:
1076
+**
1077
+** 0 p is the continuation of a prior subcommand.
1078
+**
1079
+** 1 p is text past the end of a prior subcommand.
1080
+**
1081
+** 2 p is the start of a new subcommand.
10731082
*/
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
+static int is_subcommand(Blob *p, int bAbbrevSubcmd){
1084
+ int i, sz;
1085
+ const unsigned char *z = (const unsigned char*)blob_buffer(p);
1086
+ sz = blob_size(p);
1087
+ if( sz>6 ) sz = 6;
1088
+ for(i=0; i<sz && fossil_isspace(z[i]); i++){}
1089
+ if( i>=sz ) return 0;
1090
+
1091
+ if( bAbbrevSubcmd==0 ){
1092
+ if( i>1 ) return 0;
1093
+ return z[0]=='>' ? 2 : 1;
10831094
}else{
1084
- return blob_buffer(p)[0]=='>';
1095
+ return (i==3 && fossil_isalpha(z[3])) ? 2 : 1;
10851096
}
10861097
}
10871098
10881099
/*
10891100
** Input z[] is help text for zTopic. If zTopic has sub-command zSub,
@@ -1109,28 +1120,45 @@
11091120
ReCompiled *pRe = 0;
11101121
11111122
if( bAbbrevSubcmd ){
11121123
zPattern = mprintf(" ([a-z]+ ?\\| ?)*%s\\b", zQSub);
11131124
}else{
1114
- zPattern = mprintf("> ?fossil %s .*\\b%s\\b", zQTop, zQSub);
1125
+ zPattern = mprintf("> ?fossil [-a-z]+ .*\\b%s\\b", zQSub);
11151126
}
11161127
fossil_free(zQTop);
11171128
fossil_free(zQSub);
11181129
re_compile(&pRe, zPattern, 0);
11191130
fossil_free(zPattern);
11201131
blob_init(&in, z, -1);
11211132
while( blob_line(&in, &line) ){
1122
- if( re_match(pRe, (unsigned char*)blob_buffer(&line), blob_strlen(&line)) ){
1133
+ if( re_match(pRe, (unsigned char*)blob_buffer(&line), blob_size(&line)) ){
1134
+ int atStart = 1;
11231135
blob_appendb(pOut, &line);
11241136
n++;
1125
- while( blob_line(&in, &line)
1126
- && !is_subcommand_end(&line,bAbbrevSubcmd,pRe)
1127
- ){
1128
- blob_appendb(pOut, &line);
1129
- n++;
1137
+ while( blob_line(&in, &line) ){
1138
+ if( re_match(pRe,(unsigned char*)blob_buffer(&line),blob_size(&line)) ){
1139
+ blob_appendb(pOut, &line);
1140
+ n++;
1141
+ atStart = 1;
1142
+ }else{
1143
+ int x = is_subcommand(&line,bAbbrevSubcmd);
1144
+ if( x==2 ){
1145
+ if( atStart ){
1146
+ blob_appendb(pOut, &line);
1147
+ n++;
1148
+ }else{
1149
+ break;
1150
+ }
1151
+ }else if( x==1 ){
1152
+ break;
1153
+ }else{
1154
+ blob_appendb(pOut, &line);
1155
+ n++;
1156
+ atStart = 0;
1157
+ }
1158
+ }
11301159
}
1131
- if( !bAbbrevSubcmd ) break;
11321160
}
11331161
}
11341162
blob_reset(&line);
11351163
re_free(pRe);
11361164
if( n ){
@@ -1240,11 +1268,12 @@
12401268
blob_appendb(pOut, &line);
12411269
}else if( len>7 && !fossil_isspace(zLine[0]) && bSubsectionSeen
12421270
&& sqlite3_strlike("%options:%",blob_str(&line),0)==0 ){
12431271
subsection = line;
12441272
}else if( !bAbbrevSubcmd && len>9
1245
- && (memcmp(zLine,"> fossil ",9)==0 || memcmp(zLine,"> fossil",9)) ){
1273
+ && (memcmp(zLine,"> fossil ",9)==0
1274
+ || memcmp(zLine,"> fossil",9)==0) ){
12461275
subsection = line;
12471276
bSubsectionSeen = 1;
12481277
}else if( bAbbrevSubcmd && len>5 && memcmp(zLine," ",3)==0
12491278
&& fossil_isalpha(zLine[3]) ){
12501279
subsection = line;
@@ -1347,142 +1376,10 @@
13471376
@ -U|--user USER Make the default user be USER
13481377
@ --utc Display times using UTC
13491378
@ --vfs NAME Cause SQLite to use the NAME VFS
13501379
;
13511380
1352
-/*
1353
-** COMMAND: options
1354
-**
1355
-** Usage: %fossil options [COMMAND] [SUBCOMMAND]
1356
-**
1357
-** Show available command-line options
1358
-**
1359
-** fossil options Show command-line options available
1360
-** on all commands.
1361
-**
1362
-** fossil options COMMAND Show options available on COMMAND
1363
-**
1364
-** fossil options COMMAND SUBCMD Show options specific to SUBCMD
1365
-**
1366
-** See also: [[help]], [[usage]]
1367
-*/
1368
-void options_cmd(void){
1369
- Blob s1, s2, out;
1370
- const char *z;
1371
- const char *zTopic;
1372
- int bAbbrevSubcmd = 0;
1373
-
1374
- verify_all_options();
1375
- if( g.argc>4 ){
1376
- usage("[COMMAND] [SUBCOMMAND]");
1377
- }
1378
- blob_init(&s1, 0, 0);
1379
- if( g.argc==2 ){
1380
- fossil_print("%s", zOptions);
1381
- return;
1382
- }else{
1383
- int rc;
1384
- const char *zSubtopic = g.argc==4 ? g.argv[3] : 0;
1385
- const CmdOrPage *pCmd = 0;
1386
- zTopic = g.argv[2];
1387
- rc = dispatch_name_search(zTopic, CMDFLAG_COMMAND|CMDFLAG_PREFIX, &pCmd);
1388
- if( rc ){
1389
- if( rc==1 ){
1390
- fossil_print("unknown command: %s\n", zTopic);
1391
- }else{
1392
- fossil_print("ambiguous command prefix: %s\n", zTopic);
1393
- }
1394
- return;
1395
- }
1396
- z = pCmd->zHelp;
1397
- if( z==0 ){
1398
- fossil_fatal("no help available for the %s", pCmd->zName);
1399
- }
1400
- bAbbrevSubcmd = (pCmd->eCmdFlags & CMDFLAG_ABBREVSUBCMD)!=0;
1401
- if( zSubtopic ){
1402
- if( simplify_to_subtopic(z, &s1, zTopic, zSubtopic, bAbbrevSubcmd) ){
1403
- z = blob_str(&s1);
1404
- }else{
1405
- fossil_print("No subcommand \"%s\" for \"%s\".\n", zSubtopic, zTopic);
1406
- }
1407
- }
1408
- }
1409
- blob_init(&s2, 0, 0);
1410
- simplify_to_options(z, &s2, bAbbrevSubcmd, zTopic);
1411
- blob_init(&out, 0, 0);
1412
- help_to_text(blob_str(&s2), &out, 1);
1413
- fossil_print("%s\n", blob_str(&out));
1414
- blob_reset(&out);
1415
- blob_reset(&s1);
1416
- blob_reset(&s2);
1417
-}
1418
-
1419
-/*
1420
-** COMMAND: usage
1421
-**
1422
-** Usage: %fossil usage COMMAND [SUBCOMMAND]
1423
-**
1424
-** Show succinct usage instructions for a Fossil command.
1425
-**
1426
-** See also: [[help]], [[options]]
1427
-*/
1428
-void usage_cmd(void){
1429
- int rc;
1430
- const char *zTopic;
1431
- const char *zSubtopic;
1432
- const CmdOrPage *pCmd = 0;
1433
- Blob s1, s2, out;
1434
- const char *z;
1435
- int bAbbrevSubcmd = 0;
1436
-
1437
- verify_all_options();
1438
- if( g.argc<3 || g.argc>4 ){
1439
- usage("COMMAND [SUBCOMMAND]");
1440
- }
1441
- zTopic = g.argv[2];
1442
- zSubtopic = g.argc==4 ? g.argv[3] : 0;
1443
- rc = dispatch_name_search(zTopic, CMDFLAG_COMMAND|CMDFLAG_PREFIX, &pCmd);
1444
- if( rc ){
1445
- int i, n;
1446
- const char *az[5];
1447
- if( rc==1 ){
1448
- fossil_print("unknown command: %s\n", zTopic);
1449
- }else{
1450
- fossil_print("ambiguous command prefix: %s\n", zTopic);
1451
- }
1452
- fossil_print("Did you mean one of these TOPICs:\n");
1453
- n = dispatch_approx_match(zTopic, 5, az);
1454
- for(i=0; i<n; i++){
1455
- fossil_print(" * %s\n", az[i]);
1456
- }
1457
- return;
1458
- }
1459
- bAbbrevSubcmd = (pCmd->eCmdFlags & CMDFLAG_ABBREVSUBCMD)!=0;
1460
- z = pCmd->zHelp;
1461
- if( z==0 ){
1462
- fossil_fatal("no help available for the %s", pCmd->zName);
1463
- }
1464
- blob_init(&s1, 0, 0);
1465
- blob_init(&s2, 0, 0);
1466
- if( zSubtopic!=0 ){
1467
- if( simplify_to_subtopic(z, &s1, zTopic, zSubtopic, bAbbrevSubcmd) ){
1468
- z = blob_str(&s1);
1469
- }else{
1470
- fossil_print("No subcommand \"%s\" for \"%s\".\n", zSubtopic, zTopic);
1471
- }
1472
- }
1473
- if( simplify_to_usage(z, &s2, zTopic, bAbbrevSubcmd) ){
1474
- z = blob_str(&s2);
1475
- }
1476
- blob_init(&out, 0, 0);
1477
- help_to_text(z, &out, 1);
1478
- fossil_print("%s\n", blob_str(&out));
1479
- blob_reset(&out);
1480
- blob_reset(&s1);
1481
- blob_reset(&s2);
1482
-}
1483
-
14841381
/*
14851382
** COMMAND: help
14861383
**
14871384
** Usage: %fossil help [OPTIONS] [TOPIC] [SUBCOMMAND]
14881385
**
@@ -1591,11 +1488,11 @@
15911488
z = g.argv[0];
15921489
fossil_print(
15931490
"Usage: %s help TOPIC\n"
15941491
"Things to try:\n\n"
15951492
" %s help help\n"
1596
- " %s help options\n"
1493
+ " %s help -o\n"
15971494
" %s help -a\n"
15981495
" %s search -h TOPIC\n\n"
15991496
"Other common values for TOPIC:\n\n",
16001497
z, z, z, z, z);
16011498
command_list(CMDFLAG_1ST_TIER,verboseFlag,useHtml);
@@ -1647,14 +1544,13 @@
16471544
blob_init(&s3, 0, 0);
16481545
if( zSubtopic!=0 ){
16491546
if( simplify_to_subtopic(z, &subtext1, zTopic, zSubtopic, bAbbrevSubcmd) ){
16501547
z = blob_str(&subtext1);
16511548
}else{
1652
- fossil_print("No subtopic \"%s\" for \"%s\".\n", zTopic, zSubtopic);
1653
- if( strstr(z, "Usage:")!=0 || strstr(z, "\n> ?fossil")!=0 ){
1654
- bUsage = 1;
1655
- }
1549
+ fossil_print("No subtopic \"%s\" for \"%s\".\n", zSubtopic, zTopic);
1550
+ bUsage = 1;
1551
+ zSubtopic = 0;
16561552
}
16571553
}
16581554
if( bUsage ){
16591555
if( simplify_to_usage(z, &subtext2, zTopic, bAbbrevSubcmd) ){
16601556
z = blob_str(&subtext2);
@@ -1682,11 +1578,11 @@
16821578
if( bRaw ){
16831579
blob_append(&txt, z, -1);
16841580
}else if( useHtml ){
16851581
help_to_html(z, &txt);
16861582
}else{
1687
- help_to_text(z, &txt, bUsage);
1583
+ help_to_text(z, &txt, bUsage || zSubtopic!=0);
16881584
}
16891585
if( blob_strlen(&txt)>0 ) fossil_print("%s\n", blob_str(&txt));
16901586
blob_reset(&txt);
16911587
blob_reset(&subtext1);
16921588
blob_reset(&subtext2);
16931589
--- src/dispatch.c
+++ src/dispatch.c
@@ -526,12 +526,16 @@
526 ** Format help text for TTY display.
527 */
528 static void help_to_text(const char *zHelp, Blob *pText, int bUsage){
529 int i, x;
530 char c;
531 if( !bUsage && zHelp[0]=='>' ){
532 blob_appendf(pText, "Usage:");
 
 
 
 
533 zHelp++;
534 }
535 for(i=0; (c = zHelp[i])!=0; i++){
536 if( c=='%' && strncmp(zHelp+i,"%fossil",7)==0 ){
537 if( i>0 ) blob_append(pText, zHelp, i);
@@ -1066,24 +1070,31 @@
1066 blob_reset(&buf);
1067 style_finish_page();
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 }
1087
1088 /*
1089 ** Input z[] is help text for zTopic. If zTopic has sub-command zSub,
@@ -1109,28 +1120,45 @@
1109 ReCompiled *pRe = 0;
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 }
1116 fossil_free(zQTop);
1117 fossil_free(zQSub);
1118 re_compile(&pRe, zPattern, 0);
1119 fossil_free(zPattern);
1120 blob_init(&in, z, -1);
1121 while( blob_line(&in, &line) ){
1122 if( re_match(pRe, (unsigned char*)blob_buffer(&line), blob_strlen(&line)) ){
 
1123 blob_appendb(pOut, &line);
1124 n++;
1125 while( blob_line(&in, &line)
1126 && !is_subcommand_end(&line,bAbbrevSubcmd,pRe)
1127 ){
1128 blob_appendb(pOut, &line);
1129 n++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1130 }
1131 if( !bAbbrevSubcmd ) break;
1132 }
1133 }
1134 blob_reset(&line);
1135 re_free(pRe);
1136 if( n ){
@@ -1240,11 +1268,12 @@
1240 blob_appendb(pOut, &line);
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]) ){
1250 subsection = line;
@@ -1347,142 +1376,10 @@
1347 @ -U|--user USER Make the default user be USER
1348 @ --utc Display times using UTC
1349 @ --vfs NAME Cause SQLite to use the NAME VFS
1350 ;
1351
1352 /*
1353 ** COMMAND: options
1354 **
1355 ** Usage: %fossil options [COMMAND] [SUBCOMMAND]
1356 **
1357 ** Show available command-line options
1358 **
1359 ** fossil options Show command-line options available
1360 ** on all commands.
1361 **
1362 ** fossil options COMMAND Show options available on COMMAND
1363 **
1364 ** fossil options COMMAND SUBCMD Show options specific to SUBCMD
1365 **
1366 ** See also: [[help]], [[usage]]
1367 */
1368 void options_cmd(void){
1369 Blob s1, s2, out;
1370 const char *z;
1371 const char *zTopic;
1372 int bAbbrevSubcmd = 0;
1373
1374 verify_all_options();
1375 if( g.argc>4 ){
1376 usage("[COMMAND] [SUBCOMMAND]");
1377 }
1378 blob_init(&s1, 0, 0);
1379 if( g.argc==2 ){
1380 fossil_print("%s", zOptions);
1381 return;
1382 }else{
1383 int rc;
1384 const char *zSubtopic = g.argc==4 ? g.argv[3] : 0;
1385 const CmdOrPage *pCmd = 0;
1386 zTopic = g.argv[2];
1387 rc = dispatch_name_search(zTopic, CMDFLAG_COMMAND|CMDFLAG_PREFIX, &pCmd);
1388 if( rc ){
1389 if( rc==1 ){
1390 fossil_print("unknown command: %s\n", zTopic);
1391 }else{
1392 fossil_print("ambiguous command prefix: %s\n", zTopic);
1393 }
1394 return;
1395 }
1396 z = pCmd->zHelp;
1397 if( z==0 ){
1398 fossil_fatal("no help available for the %s", pCmd->zName);
1399 }
1400 bAbbrevSubcmd = (pCmd->eCmdFlags & CMDFLAG_ABBREVSUBCMD)!=0;
1401 if( zSubtopic ){
1402 if( simplify_to_subtopic(z, &s1, zTopic, zSubtopic, bAbbrevSubcmd) ){
1403 z = blob_str(&s1);
1404 }else{
1405 fossil_print("No subcommand \"%s\" for \"%s\".\n", zSubtopic, zTopic);
1406 }
1407 }
1408 }
1409 blob_init(&s2, 0, 0);
1410 simplify_to_options(z, &s2, bAbbrevSubcmd, zTopic);
1411 blob_init(&out, 0, 0);
1412 help_to_text(blob_str(&s2), &out, 1);
1413 fossil_print("%s\n", blob_str(&out));
1414 blob_reset(&out);
1415 blob_reset(&s1);
1416 blob_reset(&s2);
1417 }
1418
1419 /*
1420 ** COMMAND: usage
1421 **
1422 ** Usage: %fossil usage COMMAND [SUBCOMMAND]
1423 **
1424 ** Show succinct usage instructions for a Fossil command.
1425 **
1426 ** See also: [[help]], [[options]]
1427 */
1428 void usage_cmd(void){
1429 int rc;
1430 const char *zTopic;
1431 const char *zSubtopic;
1432 const CmdOrPage *pCmd = 0;
1433 Blob s1, s2, out;
1434 const char *z;
1435 int bAbbrevSubcmd = 0;
1436
1437 verify_all_options();
1438 if( g.argc<3 || g.argc>4 ){
1439 usage("COMMAND [SUBCOMMAND]");
1440 }
1441 zTopic = g.argv[2];
1442 zSubtopic = g.argc==4 ? g.argv[3] : 0;
1443 rc = dispatch_name_search(zTopic, CMDFLAG_COMMAND|CMDFLAG_PREFIX, &pCmd);
1444 if( rc ){
1445 int i, n;
1446 const char *az[5];
1447 if( rc==1 ){
1448 fossil_print("unknown command: %s\n", zTopic);
1449 }else{
1450 fossil_print("ambiguous command prefix: %s\n", zTopic);
1451 }
1452 fossil_print("Did you mean one of these TOPICs:\n");
1453 n = dispatch_approx_match(zTopic, 5, az);
1454 for(i=0; i<n; i++){
1455 fossil_print(" * %s\n", az[i]);
1456 }
1457 return;
1458 }
1459 bAbbrevSubcmd = (pCmd->eCmdFlags & CMDFLAG_ABBREVSUBCMD)!=0;
1460 z = pCmd->zHelp;
1461 if( z==0 ){
1462 fossil_fatal("no help available for the %s", pCmd->zName);
1463 }
1464 blob_init(&s1, 0, 0);
1465 blob_init(&s2, 0, 0);
1466 if( zSubtopic!=0 ){
1467 if( simplify_to_subtopic(z, &s1, zTopic, zSubtopic, bAbbrevSubcmd) ){
1468 z = blob_str(&s1);
1469 }else{
1470 fossil_print("No subcommand \"%s\" for \"%s\".\n", zSubtopic, zTopic);
1471 }
1472 }
1473 if( simplify_to_usage(z, &s2, zTopic, bAbbrevSubcmd) ){
1474 z = blob_str(&s2);
1475 }
1476 blob_init(&out, 0, 0);
1477 help_to_text(z, &out, 1);
1478 fossil_print("%s\n", blob_str(&out));
1479 blob_reset(&out);
1480 blob_reset(&s1);
1481 blob_reset(&s2);
1482 }
1483
1484 /*
1485 ** COMMAND: help
1486 **
1487 ** Usage: %fossil help [OPTIONS] [TOPIC] [SUBCOMMAND]
1488 **
@@ -1591,11 +1488,11 @@
1591 z = g.argv[0];
1592 fossil_print(
1593 "Usage: %s help TOPIC\n"
1594 "Things to try:\n\n"
1595 " %s help help\n"
1596 " %s help options\n"
1597 " %s help -a\n"
1598 " %s search -h TOPIC\n\n"
1599 "Other common values for TOPIC:\n\n",
1600 z, z, z, z, z);
1601 command_list(CMDFLAG_1ST_TIER,verboseFlag,useHtml);
@@ -1647,14 +1544,13 @@
1647 blob_init(&s3, 0, 0);
1648 if( zSubtopic!=0 ){
1649 if( simplify_to_subtopic(z, &subtext1, zTopic, zSubtopic, bAbbrevSubcmd) ){
1650 z = blob_str(&subtext1);
1651 }else{
1652 fossil_print("No subtopic \"%s\" for \"%s\".\n", zTopic, zSubtopic);
1653 if( strstr(z, "Usage:")!=0 || strstr(z, "\n> ?fossil")!=0 ){
1654 bUsage = 1;
1655 }
1656 }
1657 }
1658 if( bUsage ){
1659 if( simplify_to_usage(z, &subtext2, zTopic, bAbbrevSubcmd) ){
1660 z = blob_str(&subtext2);
@@ -1682,11 +1578,11 @@
1682 if( bRaw ){
1683 blob_append(&txt, z, -1);
1684 }else if( useHtml ){
1685 help_to_html(z, &txt);
1686 }else{
1687 help_to_text(z, &txt, bUsage);
1688 }
1689 if( blob_strlen(&txt)>0 ) fossil_print("%s\n", blob_str(&txt));
1690 blob_reset(&txt);
1691 blob_reset(&subtext1);
1692 blob_reset(&subtext2);
1693
--- src/dispatch.c
+++ src/dispatch.c
@@ -526,12 +526,16 @@
526 ** Format help text for TTY display.
527 */
528 static void help_to_text(const char *zHelp, Blob *pText, int bUsage){
529 int i, x;
530 char c;
531 if( zHelp[0]=='>' ){
532 if( !bUsage ){
533 blob_appendf(pText, "Usage:");
534 }else{
535 blob_append_char(pText, ' ');
536 }
537 zHelp++;
538 }
539 for(i=0; (c = zHelp[i])!=0; i++){
540 if( c=='%' && strncmp(zHelp+i,"%fossil",7)==0 ){
541 if( i>0 ) blob_append(pText, zHelp, i);
@@ -1066,24 +1070,31 @@
1070 blob_reset(&buf);
1071 style_finish_page();
1072 }
1073
1074 /*
1075 ** Analyze p and return one of three values:
1076 **
1077 ** 0 p is the continuation of a prior subcommand.
1078 **
1079 ** 1 p is text past the end of a prior subcommand.
1080 **
1081 ** 2 p is the start of a new subcommand.
1082 */
1083 static int is_subcommand(Blob *p, int bAbbrevSubcmd){
1084 int i, sz;
1085 const unsigned char *z = (const unsigned char*)blob_buffer(p);
1086 sz = blob_size(p);
1087 if( sz>6 ) sz = 6;
1088 for(i=0; i<sz && fossil_isspace(z[i]); i++){}
1089 if( i>=sz ) return 0;
1090
1091 if( bAbbrevSubcmd==0 ){
1092 if( i>1 ) return 0;
1093 return z[0]=='>' ? 2 : 1;
1094 }else{
1095 return (i==3 && fossil_isalpha(z[3])) ? 2 : 1;
1096 }
1097 }
1098
1099 /*
1100 ** Input z[] is help text for zTopic. If zTopic has sub-command zSub,
@@ -1109,28 +1120,45 @@
1120 ReCompiled *pRe = 0;
1121
1122 if( bAbbrevSubcmd ){
1123 zPattern = mprintf(" ([a-z]+ ?\\| ?)*%s\\b", zQSub);
1124 }else{
1125 zPattern = mprintf("> ?fossil [-a-z]+ .*\\b%s\\b", zQSub);
1126 }
1127 fossil_free(zQTop);
1128 fossil_free(zQSub);
1129 re_compile(&pRe, zPattern, 0);
1130 fossil_free(zPattern);
1131 blob_init(&in, z, -1);
1132 while( blob_line(&in, &line) ){
1133 if( re_match(pRe, (unsigned char*)blob_buffer(&line), blob_size(&line)) ){
1134 int atStart = 1;
1135 blob_appendb(pOut, &line);
1136 n++;
1137 while( blob_line(&in, &line) ){
1138 if( re_match(pRe,(unsigned char*)blob_buffer(&line),blob_size(&line)) ){
1139 blob_appendb(pOut, &line);
1140 n++;
1141 atStart = 1;
1142 }else{
1143 int x = is_subcommand(&line,bAbbrevSubcmd);
1144 if( x==2 ){
1145 if( atStart ){
1146 blob_appendb(pOut, &line);
1147 n++;
1148 }else{
1149 break;
1150 }
1151 }else if( x==1 ){
1152 break;
1153 }else{
1154 blob_appendb(pOut, &line);
1155 n++;
1156 atStart = 0;
1157 }
1158 }
1159 }
 
1160 }
1161 }
1162 blob_reset(&line);
1163 re_free(pRe);
1164 if( n ){
@@ -1240,11 +1268,12 @@
1268 blob_appendb(pOut, &line);
1269 }else if( len>7 && !fossil_isspace(zLine[0]) && bSubsectionSeen
1270 && sqlite3_strlike("%options:%",blob_str(&line),0)==0 ){
1271 subsection = line;
1272 }else if( !bAbbrevSubcmd && len>9
1273 && (memcmp(zLine,"> fossil ",9)==0
1274 || memcmp(zLine,"> fossil",9)==0) ){
1275 subsection = line;
1276 bSubsectionSeen = 1;
1277 }else if( bAbbrevSubcmd && len>5 && memcmp(zLine," ",3)==0
1278 && fossil_isalpha(zLine[3]) ){
1279 subsection = line;
@@ -1347,142 +1376,10 @@
1376 @ -U|--user USER Make the default user be USER
1377 @ --utc Display times using UTC
1378 @ --vfs NAME Cause SQLite to use the NAME VFS
1379 ;
1380
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1381 /*
1382 ** COMMAND: help
1383 **
1384 ** Usage: %fossil help [OPTIONS] [TOPIC] [SUBCOMMAND]
1385 **
@@ -1591,11 +1488,11 @@
1488 z = g.argv[0];
1489 fossil_print(
1490 "Usage: %s help TOPIC\n"
1491 "Things to try:\n\n"
1492 " %s help help\n"
1493 " %s help -o\n"
1494 " %s help -a\n"
1495 " %s search -h TOPIC\n\n"
1496 "Other common values for TOPIC:\n\n",
1497 z, z, z, z, z);
1498 command_list(CMDFLAG_1ST_TIER,verboseFlag,useHtml);
@@ -1647,14 +1544,13 @@
1544 blob_init(&s3, 0, 0);
1545 if( zSubtopic!=0 ){
1546 if( simplify_to_subtopic(z, &subtext1, zTopic, zSubtopic, bAbbrevSubcmd) ){
1547 z = blob_str(&subtext1);
1548 }else{
1549 fossil_print("No subtopic \"%s\" for \"%s\".\n", zSubtopic, zTopic);
1550 bUsage = 1;
1551 zSubtopic = 0;
 
1552 }
1553 }
1554 if( bUsage ){
1555 if( simplify_to_usage(z, &subtext2, zTopic, bAbbrevSubcmd) ){
1556 z = blob_str(&subtext2);
@@ -1682,11 +1578,11 @@
1578 if( bRaw ){
1579 blob_append(&txt, z, -1);
1580 }else if( useHtml ){
1581 help_to_html(z, &txt);
1582 }else{
1583 help_to_text(z, &txt, bUsage || zSubtopic!=0);
1584 }
1585 if( blob_strlen(&txt)>0 ) fossil_print("%s\n", blob_str(&txt));
1586 blob_reset(&txt);
1587 blob_reset(&subtext1);
1588 blob_reset(&subtext2);
1589
--- src/export.c
+++ src/export.c
@@ -480,10 +480,12 @@
480480
**
481481
** See also: import
482482
*/
483483
/*
484484
** COMMAND: export*
485
+**
486
+** Usage: %fossil export --git [REPOSITORY]
485487
**
486488
** This command is deprecated. Use "fossil git export" instead.
487489
*/
488490
void export_cmd(void){
489491
Stmt q, q2, q3;
490492
--- src/export.c
+++ src/export.c
@@ -480,10 +480,12 @@
480 **
481 ** See also: import
482 */
483 /*
484 ** COMMAND: export*
 
 
485 **
486 ** This command is deprecated. Use "fossil git export" instead.
487 */
488 void export_cmd(void){
489 Stmt q, q2, q3;
490
--- src/export.c
+++ src/export.c
@@ -480,10 +480,12 @@
480 **
481 ** See also: import
482 */
483 /*
484 ** COMMAND: export*
485 **
486 ** Usage: %fossil export --git [REPOSITORY]
487 **
488 ** This command is deprecated. Use "fossil git export" instead.
489 */
490 void export_cmd(void){
491 Stmt q, q2, q3;
492

Keyboard Shortcuts

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