Fossil SCM

Improvements to rendering in the "fossil help" command, especially in combination with the -u/--usage and -o/--options command-line options.

drh 2025-03-01 16:02 trunk
Commit 62cb8ea785506f04907265173071b98839757a8ab4712b701660fbee4d8d5cf8
+1 -1
--- src/alerts.c
+++ src/alerts.c
@@ -1133,11 +1133,11 @@
11331133
** designated host and port and all times.
11341134
*/
11351135
11361136
11371137
/*
1138
-** COMMAND: alerts*
1138
+** COMMAND: alerts* abbreviated-subcommands
11391139
**
11401140
** Usage: %fossil alerts SUBCOMMAND ARGS...
11411141
**
11421142
** Subcommands:
11431143
**
11441144
--- src/alerts.c
+++ src/alerts.c
@@ -1133,11 +1133,11 @@
1133 ** designated host and port and all times.
1134 */
1135
1136
1137 /*
1138 ** COMMAND: alerts*
1139 **
1140 ** Usage: %fossil alerts SUBCOMMAND ARGS...
1141 **
1142 ** Subcommands:
1143 **
1144
--- src/alerts.c
+++ src/alerts.c
@@ -1133,11 +1133,11 @@
1133 ** designated host and port and all times.
1134 */
1135
1136
1137 /*
1138 ** COMMAND: alerts* abbreviated-subcommands
1139 **
1140 ** Usage: %fossil alerts SUBCOMMAND ARGS...
1141 **
1142 ** Subcommands:
1143 **
1144
+1 -1
--- src/allrepo.c
+++ src/allrepo.c
@@ -51,11 +51,11 @@
5151
blob_appendf(pExtra, " %s", g.argv[i]);
5252
}
5353
}
5454
5555
/*
56
-** COMMAND: all
56
+** COMMAND: all abbreviated-subcommands
5757
**
5858
** Usage: %fossil all SUBCOMMAND ...
5959
**
6060
** The ~/.fossil file records the location of all repositories for a
6161
** user. This command performs certain operations on all repositories
6262
--- src/allrepo.c
+++ src/allrepo.c
@@ -51,11 +51,11 @@
51 blob_appendf(pExtra, " %s", g.argv[i]);
52 }
53 }
54
55 /*
56 ** COMMAND: all
57 **
58 ** Usage: %fossil all SUBCOMMAND ...
59 **
60 ** The ~/.fossil file records the location of all repositories for a
61 ** user. This command performs certain operations on all repositories
62
--- src/allrepo.c
+++ src/allrepo.c
@@ -51,11 +51,11 @@
51 blob_appendf(pExtra, " %s", g.argv[i]);
52 }
53 }
54
55 /*
56 ** COMMAND: all abbreviated-subcommands
57 **
58 ** Usage: %fossil all SUBCOMMAND ...
59 **
60 ** The ~/.fossil file records the location of all repositories for a
61 ** user. This command performs certain operations on all repositories
62
+7 -7
--- src/branch.c
+++ src/branch.c
@@ -598,11 +598,11 @@
598598
** Usage: %fossil branch SUBCOMMAND ... ?OPTIONS?
599599
**
600600
** Run various subcommands to manage branches of the open repository or
601601
** of the repository identified by the -R or --repository option.
602602
**
603
-** > fossil branch close|reopen ?OPTIONS? BRANCH-NAME ?...BRANCH-NAMES?
603
+** > fossil branch close|reopen ?OPTIONS? BRANCH-NAME ?...BRANCH-NAMES?
604604
**
605605
** Adds or cancels the "closed" tag to one or more branches.
606606
** It accepts arbitrary unambiguous symbolic names but
607607
** will only resolve check-in names and skips any which resolve
608608
** to non-leaf check-ins.
@@ -612,26 +612,26 @@
612612
** to stdout
613613
** -v|--verbose Output more information
614614
** --date-override DATE DATE to use instead of 'now'
615615
** --user-override USER USER to use instead of the current default
616616
**
617
-** > fossil branch current
617
+** > fossil branch current
618618
**
619619
** Print the name of the branch for the current check-out
620620
**
621
-** > fossil branch hide|unhide ?OPTIONS? BRANCH-NAME ?...BRANCH-NAMES?
621
+** > fossil branch hide|unhide ?OPTIONS? BRANCH-NAME ?...BRANCH-NAMES?
622622
**
623623
** Adds or cancels the "hidden" tag for the specified branches or
624624
** or check-in IDs. Accepts the same options as the close
625625
** subcommand.
626626
**
627
-** > fossil branch info BRANCH-NAME
627
+** > fossil branch info BRANCH-NAME
628628
**
629629
** Print information about a branch
630630
**
631
-** > fossil branch list|ls ?OPTIONS? ?GLOB?
632
-** > fossil branch lsh ?OPTIONS? ?LIMIT?
631
+** > fossil branch list|ls ?OPTIONS? ?GLOB?
632
+** > fossil branch lsh ?OPTIONS? ?LIMIT?
633633
**
634634
** List all branches.
635635
**
636636
** Options:
637637
** -a|--all List all branches. Default show only open branches
@@ -653,11 +653,11 @@
653653
** The "lsh" variant of this subcommand shows recently changed branches,
654654
** and accepts an optional LIMIT argument (defaults to 5) to cap output,
655655
** but no GLOB argument. All other options are supported, with -t being
656656
** an implied no-op.
657657
**
658
-** > fossil branch new BRANCH-NAME BASIS ?OPTIONS?
658
+** > fossil branch new BRANCH-NAME BASIS ?OPTIONS?
659659
**
660660
** Create a new branch BRANCH-NAME off of check-in BASIS.
661661
**
662662
** Options:
663663
** --private Branch is private (i.e., remains local)
664664
--- src/branch.c
+++ src/branch.c
@@ -598,11 +598,11 @@
598 ** Usage: %fossil branch SUBCOMMAND ... ?OPTIONS?
599 **
600 ** Run various subcommands to manage branches of the open repository or
601 ** of the repository identified by the -R or --repository option.
602 **
603 ** > fossil branch close|reopen ?OPTIONS? BRANCH-NAME ?...BRANCH-NAMES?
604 **
605 ** Adds or cancels the "closed" tag to one or more branches.
606 ** It accepts arbitrary unambiguous symbolic names but
607 ** will only resolve check-in names and skips any which resolve
608 ** to non-leaf check-ins.
@@ -612,26 +612,26 @@
612 ** to stdout
613 ** -v|--verbose Output more information
614 ** --date-override DATE DATE to use instead of 'now'
615 ** --user-override USER USER to use instead of the current default
616 **
617 ** > fossil branch current
618 **
619 ** Print the name of the branch for the current check-out
620 **
621 ** > fossil branch hide|unhide ?OPTIONS? BRANCH-NAME ?...BRANCH-NAMES?
622 **
623 ** Adds or cancels the "hidden" tag for the specified branches or
624 ** or check-in IDs. Accepts the same options as the close
625 ** subcommand.
626 **
627 ** > fossil branch info BRANCH-NAME
628 **
629 ** Print information about a branch
630 **
631 ** > fossil branch list|ls ?OPTIONS? ?GLOB?
632 ** > fossil branch lsh ?OPTIONS? ?LIMIT?
633 **
634 ** List all branches.
635 **
636 ** Options:
637 ** -a|--all List all branches. Default show only open branches
@@ -653,11 +653,11 @@
653 ** The "lsh" variant of this subcommand shows recently changed branches,
654 ** and accepts an optional LIMIT argument (defaults to 5) to cap output,
655 ** but no GLOB argument. All other options are supported, with -t being
656 ** an implied no-op.
657 **
658 ** > fossil branch new BRANCH-NAME BASIS ?OPTIONS?
659 **
660 ** Create a new branch BRANCH-NAME off of check-in BASIS.
661 **
662 ** Options:
663 ** --private Branch is private (i.e., remains local)
664
--- src/branch.c
+++ src/branch.c
@@ -598,11 +598,11 @@
598 ** Usage: %fossil branch SUBCOMMAND ... ?OPTIONS?
599 **
600 ** Run various subcommands to manage branches of the open repository or
601 ** of the repository identified by the -R or --repository option.
602 **
603 ** > fossil branch close|reopen ?OPTIONS? BRANCH-NAME ?...BRANCH-NAMES?
604 **
605 ** Adds or cancels the "closed" tag to one or more branches.
606 ** It accepts arbitrary unambiguous symbolic names but
607 ** will only resolve check-in names and skips any which resolve
608 ** to non-leaf check-ins.
@@ -612,26 +612,26 @@
612 ** to stdout
613 ** -v|--verbose Output more information
614 ** --date-override DATE DATE to use instead of 'now'
615 ** --user-override USER USER to use instead of the current default
616 **
617 ** > fossil branch current
618 **
619 ** Print the name of the branch for the current check-out
620 **
621 ** > fossil branch hide|unhide ?OPTIONS? BRANCH-NAME ?...BRANCH-NAMES?
622 **
623 ** Adds or cancels the "hidden" tag for the specified branches or
624 ** or check-in IDs. Accepts the same options as the close
625 ** subcommand.
626 **
627 ** > fossil branch info BRANCH-NAME
628 **
629 ** Print information about a branch
630 **
631 ** > fossil branch list|ls ?OPTIONS? ?GLOB?
632 ** > fossil branch lsh ?OPTIONS? ?LIMIT?
633 **
634 ** List all branches.
635 **
636 ** Options:
637 ** -a|--all List all branches. Default show only open branches
@@ -653,11 +653,11 @@
653 ** The "lsh" variant of this subcommand shows recently changed branches,
654 ** and accepts an optional LIMIT argument (defaults to 5) to cap output,
655 ** but no GLOB argument. All other options are supported, with -t being
656 ** an implied no-op.
657 **
658 ** > fossil branch new BRANCH-NAME BASIS ?OPTIONS?
659 **
660 ** Create a new branch BRANCH-NAME off of check-in BASIS.
661 **
662 ** Options:
663 ** --private Branch is private (i.e., remains local)
664
+1 -1
--- src/cache.c
+++ src/cache.c
@@ -255,11 +255,11 @@
255255
void cache_initialize(void){
256256
sqlite3_close(cacheOpen(1));
257257
}
258258
259259
/*
260
-** COMMAND: cache*
260
+** COMMAND: cache* abbreviated-subcommands
261261
**
262262
** Usage: %fossil cache SUBCOMMAND
263263
**
264264
** Manage the cache used for potentially expensive web pages such as
265265
** /zip and /tarball. SUBCOMMAND can be:
266266
--- src/cache.c
+++ src/cache.c
@@ -255,11 +255,11 @@
255 void cache_initialize(void){
256 sqlite3_close(cacheOpen(1));
257 }
258
259 /*
260 ** COMMAND: cache*
261 **
262 ** Usage: %fossil cache SUBCOMMAND
263 **
264 ** Manage the cache used for potentially expensive web pages such as
265 ** /zip and /tarball. SUBCOMMAND can be:
266
--- src/cache.c
+++ src/cache.c
@@ -255,11 +255,11 @@
255 void cache_initialize(void){
256 sqlite3_close(cacheOpen(1));
257 }
258
259 /*
260 ** COMMAND: cache* abbreviated-subcommands
261 **
262 ** Usage: %fossil cache SUBCOMMAND
263 **
264 ** Manage the cache used for potentially expensive web pages such as
265 ** /zip and /tarball. SUBCOMMAND can be:
266
+123 -32
--- src/dispatch.c
+++ src/dispatch.c
@@ -54,10 +54,11 @@
5454
/* NOTE: 0x0400 = CMDFLAG_SENSITIVE in mkindex.c! */
5555
#define CMDFLAG_HIDDEN 0x0800 /* Elide from most listings */
5656
#define CMDFLAG_LDAVG_EXEMPT 0x1000 /* Exempt from load_control() */
5757
#define CMDFLAG_ALIAS 0x2000 /* Command aliases */
5858
#define CMDFLAG_KEEPEMPTY 0x4000 /* Do not unset empty settings */
59
+#define CMDFLAG_ABBREVSUBCMD 0x8000 /* Help text abbreviates subcommands */
5960
/**************************************************************************/
6061
6162
/* Values for the 2nd parameter to dispatch_name_search() */
6263
#define CMDFLAG_ANY 0x0038 /* Match anything */
6364
#define CMDFLAG_PREFIX 0x0200 /* Prefix match is ok */
@@ -522,14 +523,14 @@
522523
}
523524
524525
/*
525526
** Format help text for TTY display.
526527
*/
527
-static void help_to_text(const char *zHelp, Blob *pText){
528
+static void help_to_text(const char *zHelp, Blob *pText, int bUsage){
528529
int i, x;
529530
char c;
530
- if( zHelp[0]=='>' ){
531
+ if( !bUsage && zHelp[0]=='>' ){
531532
blob_appendf(pText, "Usage:");
532533
zHelp++;
533534
}
534535
for(i=0; (c = zHelp[i])!=0; i++){
535536
if( c=='%' && strncmp(zHelp+i,"%fossil",7)==0 ){
@@ -607,11 +608,11 @@
607608
fossil_print("# %s\n", aCommand[bktHelp[aCommand[i].iHelp][j]].zName);
608609
fossil_print("%s\n\n", aCommand[i].zHelp);
609610
}else{
610611
Blob txt;
611612
blob_init(&txt, 0, 0);
612
- help_to_text(aCommand[i].zHelp, &txt);
613
+ help_to_text(aCommand[i].zHelp, &txt, 0);
613614
for(j=0; j<occHelp[aCommand[i].iHelp]; j++){
614615
fossil_print("# %s%s\n",
615616
aCommand[bktHelp[aCommand[i].iHelp][j]].zName,
616617
(aCommand[i].eCmdFlags & CMDFLAG_VERSIONABLE)!=0 ?
617618
" (versionable)" : "");
@@ -859,11 +860,11 @@
859860
if( pCmd->zHelp[0]==0 ){
860861
@ No help available for "%h(pCmd->zName)"
861862
}else if( P("plaintext") ){
862863
Blob txt;
863864
blob_init(&txt, 0, 0);
864
- help_to_text(pCmd->zHelp, &txt);
865
+ help_to_text(pCmd->zHelp, &txt, 0);
865866
@ <pre class="helpPage">
866867
@ %h(blob_str(&txt))
867868
@ </pre>
868869
blob_reset(&txt);
869870
}else if( P("raw") ){
@@ -1063,10 +1064,28 @@
10631064
}
10641065
@ </dl>
10651066
blob_reset(&buf);
10661067
style_finish_page();
10671068
}
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
+}
10681087
10691088
/*
10701089
** Input z[] is help text for zTopic. If zTopic has sub-command zSub,
10711090
** then cut out all portions of the original help text that do not
10721091
** directly pertain to zSub and write the zSub-relevant parts into
@@ -1077,33 +1096,41 @@
10771096
*/
10781097
static int simplify_to_subtopic(
10791098
const char *z, /* Full original help text */
10801099
Blob *pOut, /* Write simplified help text here */
10811100
const char *zTopic, /* TOPIC */
1082
- const char *zSubtopic /* SUBTOPIC */
1101
+ const char *zSubtopic, /* SUBTOPIC */
1102
+ int bAbbrevSubcmd /* True if z[] contains abbreviated subcommands */
10831103
){
10841104
Blob in, line; //, subsection;
10851105
int n = 0;
10861106
char *zQTop = re_quote(zTopic);
10871107
char *zQSub = re_quote(zSubtopic);
1088
- char *zPattern = mprintf("> fossil %s .*\\b%s\\b", zQTop, zQSub);
1108
+ char *zPattern;
10891109
ReCompiled *pRe = 0;
10901110
1111
+ if( bAbbrevSubcmd ){
1112
+ zPattern = mprintf(" ([a-z]+ ?\\| ?)*%s\\b", zQSub);
1113
+ }else{
1114
+ zPattern = mprintf("> ?fossil %s .*\\b%s\\b", zQTop, zQSub);
1115
+ }
10911116
fossil_free(zQTop);
10921117
fossil_free(zQSub);
10931118
re_compile(&pRe, zPattern, 0);
10941119
fossil_free(zPattern);
10951120
blob_init(&in, z, -1);
10961121
while( blob_line(&in, &line) ){
10971122
if( re_match(pRe, (unsigned char*)blob_buffer(&line), blob_strlen(&line)) ){
10981123
blob_appendb(pOut, &line);
10991124
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
+ ){
11011128
blob_appendb(pOut, &line);
11021129
n++;
11031130
}
1104
- break;
1131
+ if( !bAbbrevSubcmd ) break;
11051132
}
11061133
}
11071134
blob_reset(&line);
11081135
re_free(pRe);
11091136
if( n ){
@@ -1110,10 +1137,43 @@
11101137
blob_trim(pOut);
11111138
blob_reset(&in);
11121139
}
11131140
return n;
11141141
}
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
+}
11151175
11161176
/*
11171177
** Input z[] is help text for a command zTopic. Write into pOut all lines of
11181178
** z[] that show the command-line syntax for that command. Lines written
11191179
** to pOut are lines that begin with out of:
@@ -1125,21 +1185,26 @@
11251185
** Return the number of lines written into pOut.
11261186
*/
11271187
static int simplify_to_usage(
11281188
const char *z, /* Full original help text */
11291189
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 */
11311192
){
11321193
ReCompiled *pRe = 0;
11331194
Blob in, line;
11341195
int n = 0;
11351196
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
+ }
11371202
blob_init(&in, z, -1);
11381203
while( blob_line(&in, &line) ){
11391204
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);
11411206
n++;
11421207
}
11431208
}
11441209
re_free(pRe);
11451210
if( n ) blob_trim(pOut);
@@ -1150,29 +1215,44 @@
11501215
** Input z[] is help text. Write into pOut all lines of z[] that show
11511216
** command-line options. Return the number of lines written.
11521217
*/
11531218
static int simplify_to_options(
11541219
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 */
11561223
){
11571224
ReCompiled *pRe = 0;
11581225
Blob txt, line, subsection;
11591226
int n = 0;
1227
+ int bSubsectionSeen = 0;
11601228
11611229
blob_init(&txt, z, -1);
11621230
blob_init(&subsection, 0, 0);
11631231
re_compile(&pRe, "^ +-.* ", 0);
11641232
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);
11691238
blob_reset(&subsection);
11701239
}
11711240
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]) ){
11731250
subsection = line;
1251
+ bSubsectionSeen = 1;
1252
+ }else if( len>1 && !fossil_isspace(zLine[0]) && bSubsectionSeen ){
1253
+ blob_reset(&subsection);
11741254
}
11751255
}
11761256
re_free(pRe);
11771257
blob_trim(pOut);
11781258
blob_reset(&subsection);
@@ -1286,10 +1366,12 @@
12861366
** See also: [[help]], [[usage]]
12871367
*/
12881368
void options_cmd(void){
12891369
Blob s1, s2, out;
12901370
const char *z;
1371
+ const char *zTopic;
1372
+ int bAbbrevSubcmd = 0;
12911373
12921374
verify_all_options();
12931375
if( g.argc>4 ){
12941376
usage("[COMMAND] [SUBCOMMAND]");
12951377
}
@@ -1297,13 +1379,13 @@
12971379
if( g.argc==2 ){
12981380
fossil_print("%s", zOptions);
12991381
return;
13001382
}else{
13011383
int rc;
1302
- const char *zTopic = g.argv[2];
13031384
const char *zSubtopic = g.argc==4 ? g.argv[3] : 0;
13041385
const CmdOrPage *pCmd = 0;
1386
+ zTopic = g.argv[2];
13051387
rc = dispatch_name_search(zTopic, CMDFLAG_COMMAND|CMDFLAG_PREFIX, &pCmd);
13061388
if( rc ){
13071389
if( rc==1 ){
13081390
fossil_print("unknown command: %s\n", zTopic);
13091391
}else{
@@ -1313,22 +1395,23 @@
13131395
}
13141396
z = pCmd->zHelp;
13151397
if( z==0 ){
13161398
fossil_fatal("no help available for the %s", pCmd->zName);
13171399
}
1400
+ bAbbrevSubcmd = (pCmd->eCmdFlags & CMDFLAG_ABBREVSUBCMD)!=0;
13181401
if( zSubtopic ){
1319
- if( simplify_to_subtopic(z, &s1, zTopic, zSubtopic) ){
1402
+ if( simplify_to_subtopic(z, &s1, zTopic, zSubtopic, bAbbrevSubcmd) ){
13201403
z = blob_str(&s1);
13211404
}else{
13221405
fossil_print("No subcommand \"%s\" for \"%s\".\n", zSubtopic, zTopic);
13231406
}
13241407
}
13251408
}
13261409
blob_init(&s2, 0, 0);
1327
- simplify_to_options(z, &s2);
1410
+ simplify_to_options(z, &s2, bAbbrevSubcmd, zTopic);
13281411
blob_init(&out, 0, 0);
1329
- help_to_text(blob_str(&s2), &out);
1412
+ help_to_text(blob_str(&s2), &out, 1);
13301413
fossil_print("%s\n", blob_str(&out));
13311414
blob_reset(&out);
13321415
blob_reset(&s1);
13331416
blob_reset(&s2);
13341417
}
@@ -1347,10 +1430,11 @@
13471430
const char *zTopic;
13481431
const char *zSubtopic;
13491432
const CmdOrPage *pCmd = 0;
13501433
Blob s1, s2, out;
13511434
const char *z;
1435
+ int bAbbrevSubcmd = 0;
13521436
13531437
verify_all_options();
13541438
if( g.argc<3 || g.argc>4 ){
13551439
usage("COMMAND [SUBCOMMAND]");
13561440
}
@@ -1370,28 +1454,29 @@
13701454
for(i=0; i<n; i++){
13711455
fossil_print(" * %s\n", az[i]);
13721456
}
13731457
return;
13741458
}
1459
+ bAbbrevSubcmd = (pCmd->eCmdFlags & CMDFLAG_ABBREVSUBCMD)!=0;
13751460
z = pCmd->zHelp;
13761461
if( z==0 ){
13771462
fossil_fatal("no help available for the %s", pCmd->zName);
13781463
}
13791464
blob_init(&s1, 0, 0);
13801465
blob_init(&s2, 0, 0);
13811466
if( zSubtopic!=0 ){
1382
- if( simplify_to_subtopic(z, &s1, zTopic, zSubtopic) ){
1467
+ if( simplify_to_subtopic(z, &s1, zTopic, zSubtopic, bAbbrevSubcmd) ){
13831468
z = blob_str(&s1);
13841469
}else{
13851470
fossil_print("No subcommand \"%s\" for \"%s\".\n", zSubtopic, zTopic);
13861471
}
13871472
}
1388
- if( simplify_to_usage(z, &s2, zTopic) ){
1473
+ if( simplify_to_usage(z, &s2, zTopic, bAbbrevSubcmd) ){
13891474
z = blob_str(&s2);
13901475
}
13911476
blob_init(&out, 0, 0);
1392
- help_to_text(z, &out);
1477
+ help_to_text(z, &out, 1);
13931478
fossil_print("%s\n", blob_str(&out));
13941479
blob_reset(&out);
13951480
blob_reset(&s1);
13961481
blob_reset(&s2);
13971482
}
@@ -1446,10 +1531,11 @@
14461531
int bOptions; /* --options */
14471532
const char *zTopic; /* TOPIC argument */
14481533
const char *zSubtopic = 0; /* SUBTOPIC argument */
14491534
Blob subtext1, subtext2, s3; /* Subsets of z[] containing subtopic/usage */
14501535
Blob txt; /* Text after rendering */
1536
+ int bAbbrevSubcmd = 0; /* Help text uses abbreviated subcommands */
14511537
14521538
verboseFlag = find_option("verbose","v",0)!=0;
14531539
commandsFlag = find_option("commands","c",0)!=0;
14541540
useHtml = find_option("html","h",0)!=0;
14551541
bRaw = find_option("raw",0,0)!=0;
@@ -1548,33 +1634,38 @@
15481634
fossil_print(" fossil help -w ;# show all web-pages\n");
15491635
fossil_print(" fossil help -s ;# show all settings\n");
15501636
fossil_print(" fossil help -o ;# show global options\n");
15511637
return;
15521638
}
1639
+ bAbbrevSubcmd = (pCmd->eCmdFlags & CMDFLAG_ABBREVSUBCMD)!=0;
15531640
z = pCmd->zHelp;
15541641
if( z==0 ){
15551642
fossil_fatal("no help available for the %s %s",
15561643
pCmd->zName, zCmdOrPage);
15571644
}
15581645
blob_init(&subtext1, 0, 0);
15591646
blob_init(&subtext2, 0, 0);
15601647
blob_init(&s3, 0, 0);
15611648
if( zSubtopic!=0 ){
1562
- if( simplify_to_subtopic(z, &subtext1, zTopic, zSubtopic) ){
1649
+ if( simplify_to_subtopic(z, &subtext1, zTopic, zSubtopic, bAbbrevSubcmd) ){
15631650
z = blob_str(&subtext1);
15641651
}else{
15651652
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 ){
15671654
bUsage = 1;
15681655
}
15691656
}
15701657
}
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
+ }
15731664
}
15741665
if( bOptions ){
1575
- simplify_to_options(z, &s3);
1666
+ simplify_to_options(z, &s3, bAbbrevSubcmd, zTopic);
15761667
z = blob_str(&s3);
15771668
}
15781669
if( pCmd && pCmd->eCmdFlags & CMDFLAG_SETTING ){
15791670
const Setting *pSetting = db_find_setting(pCmd->zName, 0);
15801671
char *zDflt = 0;
@@ -1591,13 +1682,13 @@
15911682
if( bRaw ){
15921683
blob_append(&txt, z, -1);
15931684
}else if( useHtml ){
15941685
help_to_html(z, &txt);
15951686
}else{
1596
- help_to_text(z, &txt);
1687
+ help_to_text(z, &txt, bUsage);
15971688
}
1598
- fossil_print("%s\n", blob_str(&txt));
1689
+ if( blob_strlen(&txt)>0 ) fossil_print("%s\n", blob_str(&txt));
15991690
blob_reset(&txt);
16001691
blob_reset(&subtext1);
16011692
blob_reset(&subtext2);
16021693
}
16031694
@@ -1772,11 +1863,11 @@
17721863
sqlite3_result_text(ctx, pPage->zHelp, -1, SQLITE_STATIC);
17731864
break;
17741865
case 4: { /* formatted */
17751866
Blob txt;
17761867
blob_init(&txt, 0, 0);
1777
- help_to_text(pPage->zHelp, &txt);
1868
+ help_to_text(pPage->zHelp, &txt, 0);
17781869
sqlite3_result_text(ctx, blob_str(&txt), -1, fossil_free);
17791870
break;
17801871
}
17811872
case 5: { /* formatted */
17821873
Blob txt;
17831874
--- src/dispatch.c
+++ src/dispatch.c
@@ -54,10 +54,11 @@
54 /* NOTE: 0x0400 = CMDFLAG_SENSITIVE in mkindex.c! */
55 #define CMDFLAG_HIDDEN 0x0800 /* Elide from most listings */
56 #define CMDFLAG_LDAVG_EXEMPT 0x1000 /* Exempt from load_control() */
57 #define CMDFLAG_ALIAS 0x2000 /* Command aliases */
58 #define CMDFLAG_KEEPEMPTY 0x4000 /* Do not unset empty settings */
 
59 /**************************************************************************/
60
61 /* Values for the 2nd parameter to dispatch_name_search() */
62 #define CMDFLAG_ANY 0x0038 /* Match anything */
63 #define CMDFLAG_PREFIX 0x0200 /* Prefix match is ok */
@@ -522,14 +523,14 @@
522 }
523
524 /*
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 ){
@@ -607,11 +608,11 @@
607 fossil_print("# %s\n", aCommand[bktHelp[aCommand[i].iHelp][j]].zName);
608 fossil_print("%s\n\n", aCommand[i].zHelp);
609 }else{
610 Blob txt;
611 blob_init(&txt, 0, 0);
612 help_to_text(aCommand[i].zHelp, &txt);
613 for(j=0; j<occHelp[aCommand[i].iHelp]; j++){
614 fossil_print("# %s%s\n",
615 aCommand[bktHelp[aCommand[i].iHelp][j]].zName,
616 (aCommand[i].eCmdFlags & CMDFLAG_VERSIONABLE)!=0 ?
617 " (versionable)" : "");
@@ -859,11 +860,11 @@
859 if( pCmd->zHelp[0]==0 ){
860 @ No help available for "%h(pCmd->zName)"
861 }else if( P("plaintext") ){
862 Blob txt;
863 blob_init(&txt, 0, 0);
864 help_to_text(pCmd->zHelp, &txt);
865 @ <pre class="helpPage">
866 @ %h(blob_str(&txt))
867 @ </pre>
868 blob_reset(&txt);
869 }else if( P("raw") ){
@@ -1063,10 +1064,28 @@
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
@@ -1077,33 +1096,41 @@
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; //, subsection;
1085 int n = 0;
1086 char *zQTop = re_quote(zTopic);
1087 char *zQSub = re_quote(zSubtopic);
1088 char *zPattern = mprintf("> fossil %s .*\\b%s\\b", zQTop, zQSub);
1089 ReCompiled *pRe = 0;
1090
 
 
 
 
 
1091 fossil_free(zQTop);
1092 fossil_free(zQSub);
1093 re_compile(&pRe, zPattern, 0);
1094 fossil_free(zPattern);
1095 blob_init(&in, z, -1);
1096 while( blob_line(&in, &line) ){
1097 if( re_match(pRe, (unsigned char*)blob_buffer(&line), blob_strlen(&line)) ){
1098 blob_appendb(pOut, &line);
1099 n++;
1100 while( blob_line(&in, &line) && blob_buffer(&line)[0]!='>' ){
 
 
1101 blob_appendb(pOut, &line);
1102 n++;
1103 }
1104 break;
1105 }
1106 }
1107 blob_reset(&line);
1108 re_free(pRe);
1109 if( n ){
@@ -1110,10 +1137,43 @@
1110 blob_trim(pOut);
1111 blob_reset(&in);
1112 }
1113 return n;
1114 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1115
1116 /*
1117 ** Input z[] is help text for a command zTopic. Write into pOut all lines of
1118 ** z[] that show the command-line syntax for that command. Lines written
1119 ** to pOut are lines that begin with out of:
@@ -1125,21 +1185,26 @@
1125 ** Return the number of lines written into pOut.
1126 */
1127 static int simplify_to_usage(
1128 const char *z, /* Full original help text */
1129 Blob *pOut, /* Write simplified help text here */
1130 const char *zTopic /* The command for which z[] is full help text */
 
1131 ){
1132 ReCompiled *pRe = 0;
1133 Blob in, line;
1134 int n = 0;
1135
1136 re_compile(&pRe, "^(Usage: | *[Oo]r: +%fossi |> fossil )", 0);
 
 
 
 
1137 blob_init(&in, z, -1);
1138 while( blob_line(&in, &line) ){
1139 if( re_match(pRe, (unsigned char*)blob_buffer(&line), blob_strlen(&line)) ){
1140 blob_appendb(pOut, &line);
1141 n++;
1142 }
1143 }
1144 re_free(pRe);
1145 if( n ) blob_trim(pOut);
@@ -1150,29 +1215,44 @@
1150 ** Input z[] is help text. Write into pOut all lines of z[] that show
1151 ** command-line options. Return the number of lines written.
1152 */
1153 static int simplify_to_options(
1154 const char *z, /* Full original help text */
1155 Blob *pOut /* Write simplified help text here */
 
 
1156 ){
1157 ReCompiled *pRe = 0;
1158 Blob txt, line, subsection;
1159 int n = 0;
 
1160
1161 blob_init(&txt, z, -1);
1162 blob_init(&subsection, 0, 0);
1163 re_compile(&pRe, "^ +-.* ", 0);
1164 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);
 
1169 blob_reset(&subsection);
1170 }
1171 blob_appendb(pOut, &line);
1172 }else if( len>9 && strncmp(blob_buffer(&line),"> fossil ",9)==0 ){
 
 
 
 
 
 
 
 
1173 subsection = line;
 
 
 
1174 }
1175 }
1176 re_free(pRe);
1177 blob_trim(pOut);
1178 blob_reset(&subsection);
@@ -1286,10 +1366,12 @@
1286 ** See also: [[help]], [[usage]]
1287 */
1288 void options_cmd(void){
1289 Blob s1, s2, out;
1290 const char *z;
 
 
1291
1292 verify_all_options();
1293 if( g.argc>4 ){
1294 usage("[COMMAND] [SUBCOMMAND]");
1295 }
@@ -1297,13 +1379,13 @@
1297 if( g.argc==2 ){
1298 fossil_print("%s", zOptions);
1299 return;
1300 }else{
1301 int rc;
1302 const char *zTopic = g.argv[2];
1303 const char *zSubtopic = g.argc==4 ? g.argv[3] : 0;
1304 const CmdOrPage *pCmd = 0;
 
1305 rc = dispatch_name_search(zTopic, CMDFLAG_COMMAND|CMDFLAG_PREFIX, &pCmd);
1306 if( rc ){
1307 if( rc==1 ){
1308 fossil_print("unknown command: %s\n", zTopic);
1309 }else{
@@ -1313,22 +1395,23 @@
1313 }
1314 z = pCmd->zHelp;
1315 if( z==0 ){
1316 fossil_fatal("no help available for the %s", pCmd->zName);
1317 }
 
1318 if( zSubtopic ){
1319 if( simplify_to_subtopic(z, &s1, zTopic, zSubtopic) ){
1320 z = blob_str(&s1);
1321 }else{
1322 fossil_print("No subcommand \"%s\" for \"%s\".\n", zSubtopic, zTopic);
1323 }
1324 }
1325 }
1326 blob_init(&s2, 0, 0);
1327 simplify_to_options(z, &s2);
1328 blob_init(&out, 0, 0);
1329 help_to_text(blob_str(&s2), &out);
1330 fossil_print("%s\n", blob_str(&out));
1331 blob_reset(&out);
1332 blob_reset(&s1);
1333 blob_reset(&s2);
1334 }
@@ -1347,10 +1430,11 @@
1347 const char *zTopic;
1348 const char *zSubtopic;
1349 const CmdOrPage *pCmd = 0;
1350 Blob s1, s2, out;
1351 const char *z;
 
1352
1353 verify_all_options();
1354 if( g.argc<3 || g.argc>4 ){
1355 usage("COMMAND [SUBCOMMAND]");
1356 }
@@ -1370,28 +1454,29 @@
1370 for(i=0; i<n; i++){
1371 fossil_print(" * %s\n", az[i]);
1372 }
1373 return;
1374 }
 
1375 z = pCmd->zHelp;
1376 if( z==0 ){
1377 fossil_fatal("no help available for the %s", pCmd->zName);
1378 }
1379 blob_init(&s1, 0, 0);
1380 blob_init(&s2, 0, 0);
1381 if( zSubtopic!=0 ){
1382 if( simplify_to_subtopic(z, &s1, zTopic, zSubtopic) ){
1383 z = blob_str(&s1);
1384 }else{
1385 fossil_print("No subcommand \"%s\" for \"%s\".\n", zSubtopic, zTopic);
1386 }
1387 }
1388 if( simplify_to_usage(z, &s2, zTopic) ){
1389 z = blob_str(&s2);
1390 }
1391 blob_init(&out, 0, 0);
1392 help_to_text(z, &out);
1393 fossil_print("%s\n", blob_str(&out));
1394 blob_reset(&out);
1395 blob_reset(&s1);
1396 blob_reset(&s2);
1397 }
@@ -1446,10 +1531,11 @@
1446 int bOptions; /* --options */
1447 const char *zTopic; /* TOPIC argument */
1448 const char *zSubtopic = 0; /* SUBTOPIC argument */
1449 Blob subtext1, subtext2, s3; /* Subsets of z[] containing subtopic/usage */
1450 Blob txt; /* Text after rendering */
 
1451
1452 verboseFlag = find_option("verbose","v",0)!=0;
1453 commandsFlag = find_option("commands","c",0)!=0;
1454 useHtml = find_option("html","h",0)!=0;
1455 bRaw = find_option("raw",0,0)!=0;
@@ -1548,33 +1634,38 @@
1548 fossil_print(" fossil help -w ;# show all web-pages\n");
1549 fossil_print(" fossil help -s ;# show all settings\n");
1550 fossil_print(" fossil help -o ;# show global options\n");
1551 return;
1552 }
 
1553 z = pCmd->zHelp;
1554 if( z==0 ){
1555 fossil_fatal("no help available for the %s %s",
1556 pCmd->zName, zCmdOrPage);
1557 }
1558 blob_init(&subtext1, 0, 0);
1559 blob_init(&subtext2, 0, 0);
1560 blob_init(&s3, 0, 0);
1561 if( zSubtopic!=0 ){
1562 if( simplify_to_subtopic(z, &subtext1, zTopic, zSubtopic) ){
1563 z = blob_str(&subtext1);
1564 }else{
1565 fossil_print("No subtopic \"%s\" for \"%s\".\n", zTopic, zSubtopic);
1566 if( strstr(z, "Usage:")!=0 || strstr(z, "\n> fossil")!=0 ){
1567 bUsage = 1;
1568 }
1569 }
1570 }
1571 if( bUsage && simplify_to_usage(z, &subtext2, zTopic) ){
1572 z = blob_str(&subtext2);
 
 
 
 
1573 }
1574 if( bOptions ){
1575 simplify_to_options(z, &s3);
1576 z = blob_str(&s3);
1577 }
1578 if( pCmd && pCmd->eCmdFlags & CMDFLAG_SETTING ){
1579 const Setting *pSetting = db_find_setting(pCmd->zName, 0);
1580 char *zDflt = 0;
@@ -1591,13 +1682,13 @@
1591 if( bRaw ){
1592 blob_append(&txt, z, -1);
1593 }else if( useHtml ){
1594 help_to_html(z, &txt);
1595 }else{
1596 help_to_text(z, &txt);
1597 }
1598 fossil_print("%s\n", blob_str(&txt));
1599 blob_reset(&txt);
1600 blob_reset(&subtext1);
1601 blob_reset(&subtext2);
1602 }
1603
@@ -1772,11 +1863,11 @@
1772 sqlite3_result_text(ctx, pPage->zHelp, -1, SQLITE_STATIC);
1773 break;
1774 case 4: { /* formatted */
1775 Blob txt;
1776 blob_init(&txt, 0, 0);
1777 help_to_text(pPage->zHelp, &txt);
1778 sqlite3_result_text(ctx, blob_str(&txt), -1, fossil_free);
1779 break;
1780 }
1781 case 5: { /* formatted */
1782 Blob txt;
1783
--- src/dispatch.c
+++ src/dispatch.c
@@ -54,10 +54,11 @@
54 /* NOTE: 0x0400 = CMDFLAG_SENSITIVE in mkindex.c! */
55 #define CMDFLAG_HIDDEN 0x0800 /* Elide from most listings */
56 #define CMDFLAG_LDAVG_EXEMPT 0x1000 /* Exempt from load_control() */
57 #define CMDFLAG_ALIAS 0x2000 /* Command aliases */
58 #define CMDFLAG_KEEPEMPTY 0x4000 /* Do not unset empty settings */
59 #define CMDFLAG_ABBREVSUBCMD 0x8000 /* Help text abbreviates subcommands */
60 /**************************************************************************/
61
62 /* Values for the 2nd parameter to dispatch_name_search() */
63 #define CMDFLAG_ANY 0x0038 /* Match anything */
64 #define CMDFLAG_PREFIX 0x0200 /* Prefix match is ok */
@@ -522,14 +523,14 @@
523 }
524
525 /*
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 ){
@@ -607,11 +608,11 @@
608 fossil_print("# %s\n", aCommand[bktHelp[aCommand[i].iHelp][j]].zName);
609 fossil_print("%s\n\n", aCommand[i].zHelp);
610 }else{
611 Blob txt;
612 blob_init(&txt, 0, 0);
613 help_to_text(aCommand[i].zHelp, &txt, 0);
614 for(j=0; j<occHelp[aCommand[i].iHelp]; j++){
615 fossil_print("# %s%s\n",
616 aCommand[bktHelp[aCommand[i].iHelp][j]].zName,
617 (aCommand[i].eCmdFlags & CMDFLAG_VERSIONABLE)!=0 ?
618 " (versionable)" : "");
@@ -859,11 +860,11 @@
860 if( pCmd->zHelp[0]==0 ){
861 @ No help available for "%h(pCmd->zName)"
862 }else if( P("plaintext") ){
863 Blob txt;
864 blob_init(&txt, 0, 0);
865 help_to_text(pCmd->zHelp, &txt, 0);
866 @ <pre class="helpPage">
867 @ %h(blob_str(&txt))
868 @ </pre>
869 blob_reset(&txt);
870 }else if( P("raw") ){
@@ -1063,10 +1064,28 @@
1064 }
1065 @ </dl>
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,
1090 ** then cut out all portions of the original help text that do not
1091 ** directly pertain to zSub and write the zSub-relevant parts into
@@ -1077,33 +1096,41 @@
1096 */
1097 static int simplify_to_subtopic(
1098 const char *z, /* Full original help text */
1099 Blob *pOut, /* Write simplified help text here */
1100 const char *zTopic, /* TOPIC */
1101 const char *zSubtopic, /* SUBTOPIC */
1102 int bAbbrevSubcmd /* True if z[] contains abbreviated subcommands */
1103 ){
1104 Blob in, line; //, subsection;
1105 int n = 0;
1106 char *zQTop = re_quote(zTopic);
1107 char *zQSub = re_quote(zSubtopic);
1108 char *zPattern;
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 ){
@@ -1110,10 +1137,43 @@
1137 blob_trim(pOut);
1138 blob_reset(&in);
1139 }
1140 return n;
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 }
1175
1176 /*
1177 ** Input z[] is help text for a command zTopic. Write into pOut all lines of
1178 ** z[] that show the command-line syntax for that command. Lines written
1179 ** to pOut are lines that begin with out of:
@@ -1125,21 +1185,26 @@
1185 ** Return the number of lines written into pOut.
1186 */
1187 static int simplify_to_usage(
1188 const char *z, /* Full original help text */
1189 Blob *pOut, /* Write simplified help text here */
1190 const char *zTopic, /* The command for which z[] is full help text */
1191 int bAbbrevSubcmd /* z[] uses abbreviated subcommands */
1192 ){
1193 ReCompiled *pRe = 0;
1194 Blob in, line;
1195 int n = 0;
1196
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 }
1202 blob_init(&in, z, -1);
1203 while( blob_line(&in, &line) ){
1204 if( re_match(pRe, (unsigned char*)blob_buffer(&line), blob_strlen(&line)) ){
1205 simplify_usage_line(&line, pOut, bAbbrevSubcmd, zTopic);
1206 n++;
1207 }
1208 }
1209 re_free(pRe);
1210 if( n ) blob_trim(pOut);
@@ -1150,29 +1215,44 @@
1215 ** Input z[] is help text. Write into pOut all lines of z[] that show
1216 ** command-line options. Return the number of lines written.
1217 */
1218 static int simplify_to_options(
1219 const char *z, /* Full original help text */
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 */
1223 ){
1224 ReCompiled *pRe = 0;
1225 Blob txt, line, subsection;
1226 int n = 0;
1227 int bSubsectionSeen = 0;
1228
1229 blob_init(&txt, z, -1);
1230 blob_init(&subsection, 0, 0);
1231 re_compile(&pRe, "^ +-.* ", 0);
1232 while( blob_line(&txt, &line) ){
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);
1238 blob_reset(&subsection);
1239 }
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;
1251 bSubsectionSeen = 1;
1252 }else if( len>1 && !fossil_isspace(zLine[0]) && bSubsectionSeen ){
1253 blob_reset(&subsection);
1254 }
1255 }
1256 re_free(pRe);
1257 blob_trim(pOut);
1258 blob_reset(&subsection);
@@ -1286,10 +1366,12 @@
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 }
@@ -1297,13 +1379,13 @@
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{
@@ -1313,22 +1395,23 @@
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 }
@@ -1347,10 +1430,11 @@
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 }
@@ -1370,28 +1454,29 @@
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 }
@@ -1446,10 +1531,11 @@
1531 int bOptions; /* --options */
1532 const char *zTopic; /* TOPIC argument */
1533 const char *zSubtopic = 0; /* SUBTOPIC argument */
1534 Blob subtext1, subtext2, s3; /* Subsets of z[] containing subtopic/usage */
1535 Blob txt; /* Text after rendering */
1536 int bAbbrevSubcmd = 0; /* Help text uses abbreviated subcommands */
1537
1538 verboseFlag = find_option("verbose","v",0)!=0;
1539 commandsFlag = find_option("commands","c",0)!=0;
1540 useHtml = find_option("html","h",0)!=0;
1541 bRaw = find_option("raw",0,0)!=0;
@@ -1548,33 +1634,38 @@
1634 fossil_print(" fossil help -w ;# show all web-pages\n");
1635 fossil_print(" fossil help -s ;# show all settings\n");
1636 fossil_print(" fossil help -o ;# show global options\n");
1637 return;
1638 }
1639 bAbbrevSubcmd = (pCmd->eCmdFlags & CMDFLAG_ABBREVSUBCMD)!=0;
1640 z = pCmd->zHelp;
1641 if( z==0 ){
1642 fossil_fatal("no help available for the %s %s",
1643 pCmd->zName, zCmdOrPage);
1644 }
1645 blob_init(&subtext1, 0, 0);
1646 blob_init(&subtext2, 0, 0);
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);
1661 }else{
1662 bUsage = 0;
1663 }
1664 }
1665 if( bOptions ){
1666 simplify_to_options(z, &s3, bAbbrevSubcmd, zTopic);
1667 z = blob_str(&s3);
1668 }
1669 if( pCmd && pCmd->eCmdFlags & CMDFLAG_SETTING ){
1670 const Setting *pSetting = db_find_setting(pCmd->zName, 0);
1671 char *zDflt = 0;
@@ -1591,13 +1682,13 @@
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 }
1694
@@ -1772,11 +1863,11 @@
1863 sqlite3_result_text(ctx, pPage->zHelp, -1, SQLITE_STATIC);
1864 break;
1865 case 4: { /* formatted */
1866 Blob txt;
1867 blob_init(&txt, 0, 0);
1868 help_to_text(pPage->zHelp, &txt, 0);
1869 sqlite3_result_text(ctx, blob_str(&txt), -1, fossil_free);
1870 break;
1871 }
1872 case 5: { /* formatted */
1873 Blob txt;
1874
+6 -6
--- src/hook.c
+++ src/hook.c
@@ -198,39 +198,39 @@
198198
**
199199
** Usage: %fossil hook COMMAND ...
200200
**
201201
** Commands include:
202202
**
203
-** > fossil hook add --command COMMAND --type TYPE --sequence NUMBER
203
+** > fossil hook add --command COMMAND --type TYPE --sequence NUMBER
204204
**
205205
** Create a new hook. The --command and --type arguments are
206206
** required. --sequence is optional.
207207
**
208
-** > fossil hook delete ID ...
208
+** > fossil hook delete ID ...
209209
**
210210
** Delete one or more hooks by their IDs. ID can be "all"
211211
** to delete all hooks. Caution: There is no "undo" for
212212
** this operation. Deleted hooks are permanently lost.
213213
**
214
-** > fossil hook edit --command COMMAND --type TYPE --sequence NUMBER ID ...
214
+** > fossil hook edit --command COMMAND --type TYPE --sequence NUMBER ID ...
215215
**
216216
** Make changes to one or more existing hooks. The ID argument
217217
** is either a hook-id, or a list of hook-ids, or the keyword
218218
** "all". For example, to disable hook number 2, use:
219219
**
220220
** fossil hook edit --type disabled 2
221221
**
222
-** > fossil hook list
222
+** > fossil hook list
223223
**
224224
** Show all current hooks
225225
**
226
-** > fossil hook status
226
+** > fossil hook status
227227
**
228228
** Print the values of CONFIG table entries that are relevant to
229229
** hook processing. Used for debugging.
230230
**
231
-** > fossil hook test [OPTIONS] ID
231
+** > fossil hook test [OPTIONS] ID
232232
**
233233
** Run the hook script given by ID for testing purposes.
234234
** Options:
235235
**
236236
** --dry-run Print the script on stdout rather than run it
237237
--- src/hook.c
+++ src/hook.c
@@ -198,39 +198,39 @@
198 **
199 ** Usage: %fossil hook COMMAND ...
200 **
201 ** Commands include:
202 **
203 ** > fossil hook add --command COMMAND --type TYPE --sequence NUMBER
204 **
205 ** Create a new hook. The --command and --type arguments are
206 ** required. --sequence is optional.
207 **
208 ** > fossil hook delete ID ...
209 **
210 ** Delete one or more hooks by their IDs. ID can be "all"
211 ** to delete all hooks. Caution: There is no "undo" for
212 ** this operation. Deleted hooks are permanently lost.
213 **
214 ** > fossil hook edit --command COMMAND --type TYPE --sequence NUMBER ID ...
215 **
216 ** Make changes to one or more existing hooks. The ID argument
217 ** is either a hook-id, or a list of hook-ids, or the keyword
218 ** "all". For example, to disable hook number 2, use:
219 **
220 ** fossil hook edit --type disabled 2
221 **
222 ** > fossil hook list
223 **
224 ** Show all current hooks
225 **
226 ** > fossil hook status
227 **
228 ** Print the values of CONFIG table entries that are relevant to
229 ** hook processing. Used for debugging.
230 **
231 ** > fossil hook test [OPTIONS] ID
232 **
233 ** Run the hook script given by ID for testing purposes.
234 ** Options:
235 **
236 ** --dry-run Print the script on stdout rather than run it
237
--- src/hook.c
+++ src/hook.c
@@ -198,39 +198,39 @@
198 **
199 ** Usage: %fossil hook COMMAND ...
200 **
201 ** Commands include:
202 **
203 ** > fossil hook add --command COMMAND --type TYPE --sequence NUMBER
204 **
205 ** Create a new hook. The --command and --type arguments are
206 ** required. --sequence is optional.
207 **
208 ** > fossil hook delete ID ...
209 **
210 ** Delete one or more hooks by their IDs. ID can be "all"
211 ** to delete all hooks. Caution: There is no "undo" for
212 ** this operation. Deleted hooks are permanently lost.
213 **
214 ** > fossil hook edit --command COMMAND --type TYPE --sequence NUMBER ID ...
215 **
216 ** Make changes to one or more existing hooks. The ID argument
217 ** is either a hook-id, or a list of hook-ids, or the keyword
218 ** "all". For example, to disable hook number 2, use:
219 **
220 ** fossil hook edit --type disabled 2
221 **
222 ** > fossil hook list
223 **
224 ** Show all current hooks
225 **
226 ** > fossil hook status
227 **
228 ** Print the values of CONFIG table entries that are relevant to
229 ** hook processing. Used for debugging.
230 **
231 ** > fossil hook test [OPTIONS] ID
232 **
233 ** Run the hook script given by ID for testing purposes.
234 ** Options:
235 **
236 ** --dry-run Print the script on stdout rather than run it
237
+12 -12
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -910,31 +910,31 @@
910910
if( file_isdir(zPath, ExtFILE)>0 ) *pzStore = zPath;
911911
}
912912
#endif /* FOSSIL_ENABLE_SSL */
913913
914914
/*
915
-** COMMAND: tls-config*
916
-** COMMAND: ssl-config
915
+** COMMAND: tls-config* abbreviated-subcommands
916
+** COMMAND: ssl-config abbreviated-subcommands
917917
**
918918
** Usage: %fossil ssl-config [SUBCOMMAND] [OPTIONS...] [ARGS...]
919919
**
920920
** This command is used to view or modify the TLS (Transport Layer
921921
** Security) configuration for Fossil. TLS (formerly SSL) is the
922922
** encryption technology used for secure HTTPS transport.
923923
**
924924
** Sub-commands:
925925
**
926
-** remove-exception DOMAINS Remove TLS cert exceptions for the domains
927
-** listed. Or remove them all if the --all
928
-** option is specified.
929
-**
930
-** scrub ?--force? Remove all SSL configuration data from the
931
-** repository. Use --force to omit the
932
-** confirmation.
933
-**
934
-** show ?-v? Show the TLS configuration. Add -v to see
935
-** additional explanation
926
+** remove-exception DOMAINS Remove TLS cert exceptions for the domains
927
+** listed. Or remove them all if the --all
928
+** option is specified.
929
+**
930
+** scrub ?--force? Remove all SSL configuration data from the
931
+** repository. Use --force to omit the
932
+** confirmation.
933
+**
934
+** show ?-v? Show the TLS configuration. Add -v to see
935
+** additional explanation
936936
*/
937937
void test_tlsconfig_info(void){
938938
const char *zCmd;
939939
size_t nCmd;
940940
int nHit = 0;
941941
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -910,31 +910,31 @@
910 if( file_isdir(zPath, ExtFILE)>0 ) *pzStore = zPath;
911 }
912 #endif /* FOSSIL_ENABLE_SSL */
913
914 /*
915 ** COMMAND: tls-config*
916 ** COMMAND: ssl-config
917 **
918 ** Usage: %fossil ssl-config [SUBCOMMAND] [OPTIONS...] [ARGS...]
919 **
920 ** This command is used to view or modify the TLS (Transport Layer
921 ** Security) configuration for Fossil. TLS (formerly SSL) is the
922 ** encryption technology used for secure HTTPS transport.
923 **
924 ** Sub-commands:
925 **
926 ** remove-exception DOMAINS Remove TLS cert exceptions for the domains
927 ** listed. Or remove them all if the --all
928 ** option is specified.
929 **
930 ** scrub ?--force? Remove all SSL configuration data from the
931 ** repository. Use --force to omit the
932 ** confirmation.
933 **
934 ** show ?-v? Show the TLS configuration. Add -v to see
935 ** additional explanation
936 */
937 void test_tlsconfig_info(void){
938 const char *zCmd;
939 size_t nCmd;
940 int nHit = 0;
941
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -910,31 +910,31 @@
910 if( file_isdir(zPath, ExtFILE)>0 ) *pzStore = zPath;
911 }
912 #endif /* FOSSIL_ENABLE_SSL */
913
914 /*
915 ** COMMAND: tls-config* abbreviated-subcommands
916 ** COMMAND: ssl-config abbreviated-subcommands
917 **
918 ** Usage: %fossil ssl-config [SUBCOMMAND] [OPTIONS...] [ARGS...]
919 **
920 ** This command is used to view or modify the TLS (Transport Layer
921 ** Security) configuration for Fossil. TLS (formerly SSL) is the
922 ** encryption technology used for secure HTTPS transport.
923 **
924 ** Sub-commands:
925 **
926 ** remove-exception DOMAINS Remove TLS cert exceptions for the domains
927 ** listed. Or remove them all if the --all
928 ** option is specified.
929 **
930 ** scrub ?--force? Remove all SSL configuration data from the
931 ** repository. Use --force to omit the
932 ** confirmation.
933 **
934 ** show ?-v? Show the TLS configuration. Add -v to see
935 ** additional explanation
936 */
937 void test_tlsconfig_info(void){
938 const char *zCmd;
939 size_t nCmd;
940 int nHit = 0;
941
+3 -3
--- src/interwiki.c
+++ src/interwiki.c
@@ -161,23 +161,23 @@
161161
** Usage: %fossil interwiki COMMAND ...
162162
**
163163
** Manage the "intermap" that defines the mapping from interwiki tags
164164
** to complete URLs for interwiki links.
165165
**
166
-** > fossil interwiki delete TAG ...
166
+** > fossil interwiki delete TAG ...
167167
**
168168
** Delete one or more interwiki maps.
169169
**
170
-** > fossil interwiki edit TAG --base URL --hash PATH --wiki PATH
170
+** > fossil interwiki edit TAG --base URL --hash PATH --wiki PATH
171171
**
172172
** Create an interwiki referenced call TAG. The base URL is
173173
** the --base option, which is required. The --hash and --wiki
174174
** paths are optional. The TAG must be lower-case alphanumeric
175175
** and must be unique. A new entry is created if it does not
176176
** already exit.
177177
**
178
-** > fossil interwiki list
178
+** > fossil interwiki list
179179
**
180180
** Show all interwiki mappings.
181181
*/
182182
void interwiki_cmd(void){
183183
const char *zCmd;
184184
--- src/interwiki.c
+++ src/interwiki.c
@@ -161,23 +161,23 @@
161 ** Usage: %fossil interwiki COMMAND ...
162 **
163 ** Manage the "intermap" that defines the mapping from interwiki tags
164 ** to complete URLs for interwiki links.
165 **
166 ** > fossil interwiki delete TAG ...
167 **
168 ** Delete one or more interwiki maps.
169 **
170 ** > fossil interwiki edit TAG --base URL --hash PATH --wiki PATH
171 **
172 ** Create an interwiki referenced call TAG. The base URL is
173 ** the --base option, which is required. The --hash and --wiki
174 ** paths are optional. The TAG must be lower-case alphanumeric
175 ** and must be unique. A new entry is created if it does not
176 ** already exit.
177 **
178 ** > fossil interwiki list
179 **
180 ** Show all interwiki mappings.
181 */
182 void interwiki_cmd(void){
183 const char *zCmd;
184
--- src/interwiki.c
+++ src/interwiki.c
@@ -161,23 +161,23 @@
161 ** Usage: %fossil interwiki COMMAND ...
162 **
163 ** Manage the "intermap" that defines the mapping from interwiki tags
164 ** to complete URLs for interwiki links.
165 **
166 ** > fossil interwiki delete TAG ...
167 **
168 ** Delete one or more interwiki maps.
169 **
170 ** > fossil interwiki edit TAG --base URL --hash PATH --wiki PATH
171 **
172 ** Create an interwiki referenced call TAG. The base URL is
173 ** the --base option, which is required. The --hash and --wiki
174 ** paths are optional. The TAG must be lower-case alphanumeric
175 ** and must be unique. A new entry is created if it does not
176 ** already exit.
177 **
178 ** > fossil interwiki list
179 **
180 ** Show all interwiki mappings.
181 */
182 void interwiki_cmd(void){
183 const char *zCmd;
184
+1 -1
--- src/rebuild.c
+++ src/rebuild.c
@@ -1414,11 +1414,11 @@
14141414
}
14151415
14161416
/*
14171417
** COMMAND: deconstruct*
14181418
**
1419
-** Usage %fossil deconstruct ?OPTIONS? DESTINATION
1419
+** Usage: %fossil deconstruct ?OPTIONS? DESTINATION
14201420
**
14211421
** This command exports all artifacts of a given repository and writes all
14221422
** artifacts to the file system. The DESTINATION directory will be populated
14231423
** with subdirectories AA and files AA/BBBBBBBBB.., where AABBBBBBBBB.. is the
14241424
** 40+ character artifact ID, AA the first 2 characters.
14251425
--- src/rebuild.c
+++ src/rebuild.c
@@ -1414,11 +1414,11 @@
1414 }
1415
1416 /*
1417 ** COMMAND: deconstruct*
1418 **
1419 ** Usage %fossil deconstruct ?OPTIONS? DESTINATION
1420 **
1421 ** This command exports all artifacts of a given repository and writes all
1422 ** artifacts to the file system. The DESTINATION directory will be populated
1423 ** with subdirectories AA and files AA/BBBBBBBBB.., where AABBBBBBBBB.. is the
1424 ** 40+ character artifact ID, AA the first 2 characters.
1425
--- src/rebuild.c
+++ src/rebuild.c
@@ -1414,11 +1414,11 @@
1414 }
1415
1416 /*
1417 ** COMMAND: deconstruct*
1418 **
1419 ** Usage: %fossil deconstruct ?OPTIONS? DESTINATION
1420 **
1421 ** This command exports all artifacts of a given repository and writes all
1422 ** artifacts to the file system. The DESTINATION directory will be populated
1423 ** with subdirectories AA and files AA/BBBBBBBBB.., where AABBBBBBBBB.. is the
1424 ** 40+ character artifact ID, AA the first 2 characters.
1425
+16 -16
--- src/search.c
+++ src/search.c
@@ -2291,32 +2291,32 @@
22912291
}
22922292
fossil_print(" done\n");
22932293
}
22942294
22952295
/*
2296
-** COMMAND: fts-config*
2296
+** COMMAND: fts-config* abbreviated-subcommands
22972297
**
22982298
** Usage: fossil fts-config ?SUBCOMMAND? ?ARGUMENT?
22992299
**
23002300
** The "fossil fts-config" command configures the full-text search capabilities
23012301
** of the repository. Subcommands:
23022302
**
2303
-** reindex Rebuild the search index. This is a no-op if
2304
-** index search is disabled
2305
-**
2306
-** index (on|off) Turn the search index on or off
2307
-**
2308
-** enable TYPE .. Enable search for TYPE. TYPE is one of:
2309
-** check-in, document, ticket, wiki, technote,
2310
-** forum, help, or all
2311
-**
2312
-** disable TYPE ... Disable search for TYPE
2313
-**
2314
-** tokenizer VALUE Select a tokenizer for indexed search. VALUE
2315
-** may be one of (porter, on, off, trigram, unicode61),
2316
-** and "on" is equivalent to "porter". Unindexed
2317
-** search never uses tokenization or stemming.
2303
+** reindex Rebuild the search index. This is a no-op if
2304
+** index search is disabled
2305
+**
2306
+** index (on|off) Turn the search index on or off
2307
+**
2308
+** enable TYPE .. Enable search for TYPE. TYPE is one of:
2309
+** check-in, document, ticket, wiki, technote,
2310
+** forum, help, or all
2311
+**
2312
+** disable TYPE ... Disable search for TYPE
2313
+**
2314
+** tokenizer VALUE Select a tokenizer for indexed search. VALUE
2315
+** may be one of (porter, on, off, trigram, unicode61),
2316
+** and "on" is equivalent to "porter". Unindexed
2317
+** search never uses tokenization or stemming.
23182318
**
23192319
** The current search settings are displayed after any changes are applied.
23202320
** Run this command with no arguments to simply see the settings.
23212321
*/
23222322
void fts_config_cmd(void){
23232323
--- src/search.c
+++ src/search.c
@@ -2291,32 +2291,32 @@
2291 }
2292 fossil_print(" done\n");
2293 }
2294
2295 /*
2296 ** COMMAND: fts-config*
2297 **
2298 ** Usage: fossil fts-config ?SUBCOMMAND? ?ARGUMENT?
2299 **
2300 ** The "fossil fts-config" command configures the full-text search capabilities
2301 ** of the repository. Subcommands:
2302 **
2303 ** reindex Rebuild the search index. This is a no-op if
2304 ** index search is disabled
2305 **
2306 ** index (on|off) Turn the search index on or off
2307 **
2308 ** enable TYPE .. Enable search for TYPE. TYPE is one of:
2309 ** check-in, document, ticket, wiki, technote,
2310 ** forum, help, or all
2311 **
2312 ** disable TYPE ... Disable search for TYPE
2313 **
2314 ** tokenizer VALUE Select a tokenizer for indexed search. VALUE
2315 ** may be one of (porter, on, off, trigram, unicode61),
2316 ** and "on" is equivalent to "porter". Unindexed
2317 ** search never uses tokenization or stemming.
2318 **
2319 ** The current search settings are displayed after any changes are applied.
2320 ** Run this command with no arguments to simply see the settings.
2321 */
2322 void fts_config_cmd(void){
2323
--- src/search.c
+++ src/search.c
@@ -2291,32 +2291,32 @@
2291 }
2292 fossil_print(" done\n");
2293 }
2294
2295 /*
2296 ** COMMAND: fts-config* abbreviated-subcommands
2297 **
2298 ** Usage: fossil fts-config ?SUBCOMMAND? ?ARGUMENT?
2299 **
2300 ** The "fossil fts-config" command configures the full-text search capabilities
2301 ** of the repository. Subcommands:
2302 **
2303 ** reindex Rebuild the search index. This is a no-op if
2304 ** index search is disabled
2305 **
2306 ** index (on|off) Turn the search index on or off
2307 **
2308 ** enable TYPE .. Enable search for TYPE. TYPE is one of:
2309 ** check-in, document, ticket, wiki, technote,
2310 ** forum, help, or all
2311 **
2312 ** disable TYPE ... Disable search for TYPE
2313 **
2314 ** tokenizer VALUE Select a tokenizer for indexed search. VALUE
2315 ** may be one of (porter, on, off, trigram, unicode61),
2316 ** and "on" is equivalent to "porter". Unindexed
2317 ** search never uses tokenization or stemming.
2318 **
2319 ** The current search settings are displayed after any changes are applied.
2320 ** Run this command with no arguments to simply see the settings.
2321 */
2322 void fts_config_cmd(void){
2323
--- src/unversioned.c
+++ src/unversioned.c
@@ -218,12 +218,12 @@
218218
}
219219
return 0;
220220
}
221221
222222
/*
223
-** COMMAND: uv#
224
-** COMMAND: unversioned
223
+** COMMAND: uv# abbreviated-subcommands
224
+** COMMAND: unversioned abbreviated-subcommands
225225
**
226226
** Usage: %fossil unversioned SUBCOMMAND ARGS...
227227
** or: %fossil uv SUBCOMMAND ARGS..
228228
**
229229
** Unversioned files (UV-files) are artifacts that are synced and are available
230230
--- src/unversioned.c
+++ src/unversioned.c
@@ -218,12 +218,12 @@
218 }
219 return 0;
220 }
221
222 /*
223 ** COMMAND: uv#
224 ** COMMAND: unversioned
225 **
226 ** Usage: %fossil unversioned SUBCOMMAND ARGS...
227 ** or: %fossil uv SUBCOMMAND ARGS..
228 **
229 ** Unversioned files (UV-files) are artifacts that are synced and are available
230
--- src/unversioned.c
+++ src/unversioned.c
@@ -218,12 +218,12 @@
218 }
219 return 0;
220 }
221
222 /*
223 ** COMMAND: uv# abbreviated-subcommands
224 ** COMMAND: unversioned abbreviated-subcommands
225 **
226 ** Usage: %fossil unversioned SUBCOMMAND ARGS...
227 ** or: %fossil uv SUBCOMMAND ARGS..
228 **
229 ** Unversioned files (UV-files) are artifacts that are synced and are available
230
+1 -2
--- src/user.c
+++ src/user.c
@@ -331,12 +331,11 @@
331331
** > fossil user default ?USERNAME?
332332
**
333333
** Query or set the default user. The default user is the
334334
** user for command-line interaction.
335335
**
336
-** > fossil user list
337
-** > fossil user ls
336
+** > fossil user list | ls
338337
**
339338
** List all users known to the repository
340339
**
341340
** > fossil user new ?USERNAME? ?CONTACT-INFO? ?PASSWORD?
342341
**
343342
--- src/user.c
+++ src/user.c
@@ -331,12 +331,11 @@
331 ** > fossil user default ?USERNAME?
332 **
333 ** Query or set the default user. The default user is the
334 ** user for command-line interaction.
335 **
336 ** > fossil user list
337 ** > fossil user ls
338 **
339 ** List all users known to the repository
340 **
341 ** > fossil user new ?USERNAME? ?CONTACT-INFO? ?PASSWORD?
342 **
343
--- src/user.c
+++ src/user.c
@@ -331,12 +331,11 @@
331 ** > fossil user default ?USERNAME?
332 **
333 ** Query or set the default user. The default user is the
334 ** user for command-line interaction.
335 **
336 ** > fossil user list | ls
 
337 **
338 ** List all users known to the repository
339 **
340 ** > fossil user new ?USERNAME? ?CONTACT-INFO? ?PASSWORD?
341 **
342
--- tools/mkindex.c
+++ tools/mkindex.c
@@ -100,10 +100,11 @@
100100
#define CMDFLAG_SENSITIVE 0x0400 /* Security-sensitive setting */
101101
#define CMDFLAG_HIDDEN 0x0800 /* Elide from most listings */
102102
#define CMDFLAG_LDAVG_EXEMPT 0x1000 /* Exempt from load_control() */
103103
#define CMDFLAG_ALIAS 0x2000 /* Command aliases */
104104
#define CMDFLAG_KEEPEMPTY 0x4000 /* Do not unset empty settings */
105
+#define CMDFLAG_ABBREVSUBCMD 0x8000 /* Abbreviated subcmd in help text */
105106
/**************************************************************************/
106107
107108
/*
108109
** Each entry looks like this:
109110
*/
@@ -280,10 +281,12 @@
280281
aEntry[nUsed].zVar = string_dup(&zLine[i+9], j-9);
281282
}else if( j==6 && strncmp(&zLine[i], "hidden", 6)==0 ){
282283
aEntry[nUsed].eType |= CMDFLAG_HIDDEN;
283284
}else if( j==14 && strncmp(&zLine[i], "loadavg-exempt", 14)==0 ){
284285
aEntry[nUsed].eType |= CMDFLAG_LDAVG_EXEMPT;
286
+ }else if( j==23 && strncmp(&zLine[i], "abbreviated-subcommands", 23)==0 ){
287
+ aEntry[nUsed].eType |= CMDFLAG_ABBREVSUBCMD;
285288
}else{
286289
fprintf(stderr, "%s:%d: unknown option: '%.*s'\n",
287290
zFile, nLine, j, &zLine[i]);
288291
nErr++;
289292
}
290293
--- tools/mkindex.c
+++ tools/mkindex.c
@@ -100,10 +100,11 @@
100 #define CMDFLAG_SENSITIVE 0x0400 /* Security-sensitive setting */
101 #define CMDFLAG_HIDDEN 0x0800 /* Elide from most listings */
102 #define CMDFLAG_LDAVG_EXEMPT 0x1000 /* Exempt from load_control() */
103 #define CMDFLAG_ALIAS 0x2000 /* Command aliases */
104 #define CMDFLAG_KEEPEMPTY 0x4000 /* Do not unset empty settings */
 
105 /**************************************************************************/
106
107 /*
108 ** Each entry looks like this:
109 */
@@ -280,10 +281,12 @@
280 aEntry[nUsed].zVar = string_dup(&zLine[i+9], j-9);
281 }else if( j==6 && strncmp(&zLine[i], "hidden", 6)==0 ){
282 aEntry[nUsed].eType |= CMDFLAG_HIDDEN;
283 }else if( j==14 && strncmp(&zLine[i], "loadavg-exempt", 14)==0 ){
284 aEntry[nUsed].eType |= CMDFLAG_LDAVG_EXEMPT;
 
 
285 }else{
286 fprintf(stderr, "%s:%d: unknown option: '%.*s'\n",
287 zFile, nLine, j, &zLine[i]);
288 nErr++;
289 }
290
--- tools/mkindex.c
+++ tools/mkindex.c
@@ -100,10 +100,11 @@
100 #define CMDFLAG_SENSITIVE 0x0400 /* Security-sensitive setting */
101 #define CMDFLAG_HIDDEN 0x0800 /* Elide from most listings */
102 #define CMDFLAG_LDAVG_EXEMPT 0x1000 /* Exempt from load_control() */
103 #define CMDFLAG_ALIAS 0x2000 /* Command aliases */
104 #define CMDFLAG_KEEPEMPTY 0x4000 /* Do not unset empty settings */
105 #define CMDFLAG_ABBREVSUBCMD 0x8000 /* Abbreviated subcmd in help text */
106 /**************************************************************************/
107
108 /*
109 ** Each entry looks like this:
110 */
@@ -280,10 +281,12 @@
281 aEntry[nUsed].zVar = string_dup(&zLine[i+9], j-9);
282 }else if( j==6 && strncmp(&zLine[i], "hidden", 6)==0 ){
283 aEntry[nUsed].eType |= CMDFLAG_HIDDEN;
284 }else if( j==14 && strncmp(&zLine[i], "loadavg-exempt", 14)==0 ){
285 aEntry[nUsed].eType |= CMDFLAG_LDAVG_EXEMPT;
286 }else if( j==23 && strncmp(&zLine[i], "abbreviated-subcommands", 23)==0 ){
287 aEntry[nUsed].eType |= CMDFLAG_ABBREVSUBCMD;
288 }else{
289 fprintf(stderr, "%s:%d: unknown option: '%.*s'\n",
290 zFile, nLine, j, &zLine[i]);
291 nErr++;
292 }
293

Keyboard Shortcuts

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