Fossil SCM

Add aliases as a new command type and display these next to the corresponding main command in /help. Make sure that for the 'test-all-help' command and webpage each help string is output at most once.

danield 2022-09-01 10:52 trunk merge
Commit db708494958373595e26f95acf9c0c3847b1d2913df4dc2053b7830f37911273
+1 -1
--- src/checkin.c
+++ src/checkin.c
@@ -2088,11 +2088,11 @@
20882088
char **pB = (char**)b;
20892089
return fossil_strcmp(pA[0], pB[0]);
20902090
}
20912091
20922092
/*
2093
-** COMMAND: ci*
2093
+** COMMAND: ci#
20942094
** COMMAND: commit
20952095
**
20962096
** Usage: %fossil commit ?OPTIONS? ?FILE...?
20972097
** or: %fossil ci ?OPTIONS? ?FILE...?
20982098
**
20992099
--- src/checkin.c
+++ src/checkin.c
@@ -2088,11 +2088,11 @@
2088 char **pB = (char**)b;
2089 return fossil_strcmp(pA[0], pB[0]);
2090 }
2091
2092 /*
2093 ** COMMAND: ci*
2094 ** COMMAND: commit
2095 **
2096 ** Usage: %fossil commit ?OPTIONS? ?FILE...?
2097 ** or: %fossil ci ?OPTIONS? ?FILE...?
2098 **
2099
--- src/checkin.c
+++ src/checkin.c
@@ -2088,11 +2088,11 @@
2088 char **pB = (char**)b;
2089 return fossil_strcmp(pA[0], pB[0]);
2090 }
2091
2092 /*
2093 ** COMMAND: ci#
2094 ** COMMAND: commit
2095 **
2096 ** Usage: %fossil commit ?OPTIONS? ?FILE...?
2097 ** or: %fossil ci ?OPTIONS? ?FILE...?
2098 **
2099
+1 -1
--- src/checkout.c
+++ src/checkout.c
@@ -257,11 +257,11 @@
257257
}
258258
259259
260260
/*
261261
** COMMAND: checkout*
262
-** COMMAND: co*
262
+** COMMAND: co#
263263
**
264264
** Usage: %fossil checkout ?VERSION | --latest? ?OPTIONS?
265265
** or: %fossil co ?VERSION | --latest? ?OPTIONS?
266266
**
267267
** NOTE: Most people use "fossil update" instead of "fossil checkout" for
268268
--- src/checkout.c
+++ src/checkout.c
@@ -257,11 +257,11 @@
257 }
258
259
260 /*
261 ** COMMAND: checkout*
262 ** COMMAND: co*
263 **
264 ** Usage: %fossil checkout ?VERSION | --latest? ?OPTIONS?
265 ** or: %fossil co ?VERSION | --latest? ?OPTIONS?
266 **
267 ** NOTE: Most people use "fossil update" instead of "fossil checkout" for
268
--- src/checkout.c
+++ src/checkout.c
@@ -257,11 +257,11 @@
257 }
258
259
260 /*
261 ** COMMAND: checkout*
262 ** COMMAND: co#
263 **
264 ** Usage: %fossil checkout ?VERSION | --latest? ?OPTIONS?
265 ** or: %fossil co ?VERSION | --latest? ?OPTIONS?
266 **
267 ** NOTE: Most people use "fossil update" instead of "fossil checkout" for
268
+1 -1
--- src/db.c
+++ src/db.c
@@ -2803,11 +2803,11 @@
28032803
manifest_crosslink(rid, &manifest, MC_NONE);
28042804
}
28052805
}
28062806
28072807
/*
2808
-** COMMAND: new*
2808
+** COMMAND: new#
28092809
** COMMAND: init
28102810
**
28112811
** Usage: %fossil new ?OPTIONS? FILENAME
28122812
** or: %fossil init ?OPTIONS? FILENAME
28132813
**
28142814
--- src/db.c
+++ src/db.c
@@ -2803,11 +2803,11 @@
2803 manifest_crosslink(rid, &manifest, MC_NONE);
2804 }
2805 }
2806
2807 /*
2808 ** COMMAND: new*
2809 ** COMMAND: init
2810 **
2811 ** Usage: %fossil new ?OPTIONS? FILENAME
2812 ** or: %fossil init ?OPTIONS? FILENAME
2813 **
2814
--- src/db.c
+++ src/db.c
@@ -2803,11 +2803,11 @@
2803 manifest_crosslink(rid, &manifest, MC_NONE);
2804 }
2805 }
2806
2807 /*
2808 ** COMMAND: new#
2809 ** COMMAND: init
2810 **
2811 ** Usage: %fossil new ?OPTIONS? FILENAME
2812 ** or: %fossil init ?OPTIONS? FILENAME
2813 **
2814
--- src/default.css
+++ src/default.css
@@ -236,10 +236,13 @@
236236
}
237237
.columns li {
238238
break-inside: avoid;
239239
page-break-inside: avoid;
240240
}
241
+body.help .columns li {
242
+ white-space: nowrap /* keep command name aliases from wrapping */;
243
+}
241244
.filetree {
242245
margin: 1em 0;
243246
line-height: 1.5;
244247
}
245248
.filetree > ul {
246249
--- src/default.css
+++ src/default.css
@@ -236,10 +236,13 @@
236 }
237 .columns li {
238 break-inside: avoid;
239 page-break-inside: avoid;
240 }
 
 
 
241 .filetree {
242 margin: 1em 0;
243 line-height: 1.5;
244 }
245 .filetree > ul {
246
--- src/default.css
+++ src/default.css
@@ -236,10 +236,13 @@
236 }
237 .columns li {
238 break-inside: avoid;
239 page-break-inside: avoid;
240 }
241 body.help .columns li {
242 white-space: nowrap /* keep command name aliases from wrapping */;
243 }
244 .filetree {
245 margin: 1em 0;
246 line-height: 1.5;
247 }
248 .filetree > ul {
249
+124 -31
--- src/dispatch.c
+++ src/dispatch.c
@@ -31,10 +31,11 @@
3131
*/
3232
struct CmdOrPage {
3333
const char *zName; /* Name. Webpages start with "/". Commands do not */
3434
void (*xFunc)(void); /* Implementation function, or NULL for settings */
3535
const char *zHelp; /* Raw help text */
36
+ int iHelp; /* Index of help variable */
3637
unsigned int eCmdFlags; /* Flags */
3738
};
3839
3940
/***************************************************************************
4041
** These macros must match similar macros in mkindex.c
@@ -51,10 +52,11 @@
5152
#define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
5253
#define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret POST content */
5354
/* NOTE: 0x0400 = CMDFLAG_SENSITIVE in mkindex.c! */
5455
#define CMDFLAG_HIDDEN 0x0800 /* Elide from most listings */
5556
#define CMDFLAG_LDAVG_EXEMPT 0x1000 /* Exempt from load_control() */
57
+#define CMDFLAG_ALIAS 0x2000 /* Command aliases */
5658
/**************************************************************************/
5759
5860
/* Values for the 2nd parameter to dispatch_name_search() */
5961
#define CMDFLAG_ANY 0x0038 /* Match anything */
6062
#define CMDFLAG_PREFIX 0x0200 /* Prefix match is ok */
@@ -77,10 +79,11 @@
7779
** source code files looking for header comments on the functions that
7880
** implement command and webpages.
7981
*/
8082
#include "page_index.h"
8183
#define MX_COMMAND count(aCommand)
84
+#define MX_HELP_DUP 5 /* Upper bound estimate on help string duplication */
8285
8386
/*
8487
** Given a command, webpage, or setting name in zName, find the corresponding
8588
** CmdOrPage object and return a pointer to that object in *ppCmd.
8689
**
@@ -546,45 +549,65 @@
546549
/*
547550
** Display help for all commands based on provided flags.
548551
*/
549552
static void display_all_help(int mask, int useHtml, int rawOut){
550553
int i;
554
+ unsigned char occHelp[FOSSIL_MX_CMDIDX] = {0}; /* Help string occurrences */
555
+ int bktHelp[FOSSIL_MX_CMDIDX][MX_HELP_DUP] = {0};/* Help strings -> commands*/
551556
if( useHtml ) fossil_print("<!--\n");
552557
fossil_print("Help text for:\n");
553558
if( mask & CMDFLAG_1ST_TIER ) fossil_print(" * Commands\n");
554559
if( mask & CMDFLAG_2ND_TIER ) fossil_print(" * Auxiliary commands\n");
560
+ if( mask & CMDFLAG_ALIAS ) fossil_print(" * Aliases\n");
555561
if( mask & CMDFLAG_TEST ) fossil_print(" * Test commands\n");
556562
if( mask & CMDFLAG_WEBPAGE ) fossil_print(" * Web pages\n");
557563
if( mask & CMDFLAG_SETTING ) fossil_print(" * Settings\n");
558564
if( useHtml ){
559565
fossil_print("-->\n");
560566
fossil_print("<!-- start_all_help -->\n");
561567
}else{
562568
fossil_print("---\n");
563569
}
570
+ /* Fill in help string buckets */
571
+ for(i=0; i<MX_COMMAND; i++){
572
+ if( (aCommand[i].eCmdFlags & mask)==0 ) continue;
573
+ else if(aCommand[i].eCmdFlags & CMDFLAG_HIDDEN) continue;
574
+ bktHelp[aCommand[i].iHelp][occHelp[aCommand[i].iHelp]++] = i;
575
+ }
564576
for(i=0; i<MX_COMMAND; i++){
565577
if( (aCommand[i].eCmdFlags & mask)==0 ) continue;
566578
else if(aCommand[i].eCmdFlags & CMDFLAG_HIDDEN) continue;
567
- if( useHtml ){
568
- Blob html;
569
- blob_init(&html, 0, 0);
570
- help_to_html(aCommand[i].zHelp, &html);
571
- fossil_print("<h1>%h</h1>\n", aCommand[i].zName);
572
- fossil_print("%s\n<hr>\n", blob_str(&html));
573
- blob_reset(&html);
574
- }else if( rawOut ){
575
- fossil_print("# %s\n", aCommand[i].zName);
576
- fossil_print("%s\n\n", aCommand[i].zHelp);
577
- }else{
578
- Blob txt;
579
- blob_init(&txt, 0, 0);
580
- help_to_text(aCommand[i].zHelp, &txt);
581
- fossil_print("# %s%s\n", aCommand[i].zName,
582
- (aCommand[i].eCmdFlags & CMDFLAG_VERSIONABLE)!=0 ?
583
- " (versionable)" : "");
584
- fossil_print("%s\n\n", blob_str(&txt));
585
- blob_reset(&txt);
579
+ if( occHelp[aCommand[i].iHelp] > 0 ){
580
+ int j;
581
+ if( useHtml ){
582
+ Blob html;
583
+ blob_init(&html, 0, 0);
584
+ help_to_html(aCommand[i].zHelp, &html);
585
+ for(j=0; j<occHelp[aCommand[i].iHelp]; j++){
586
+ fossil_print("<h1>%h</h1>\n",
587
+ aCommand[bktHelp[aCommand[i].iHelp][j]].zName);
588
+ }
589
+ fossil_print("%s\n<hr>\n", blob_str(&html));
590
+ blob_reset(&html);
591
+ }else if( rawOut ){
592
+ for(j=0; j<occHelp[aCommand[i].iHelp]; j++)
593
+ fossil_print("# %s\n", aCommand[bktHelp[aCommand[i].iHelp][j]].zName);
594
+ fossil_print("%s\n\n", aCommand[i].zHelp);
595
+ }else{
596
+ Blob txt;
597
+ blob_init(&txt, 0, 0);
598
+ help_to_text(aCommand[i].zHelp, &txt);
599
+ for(j=0; j<occHelp[aCommand[i].iHelp]; j++){
600
+ fossil_print("# %s%s\n",
601
+ aCommand[bktHelp[aCommand[i].iHelp][j]].zName,
602
+ (aCommand[i].eCmdFlags & CMDFLAG_VERSIONABLE)!=0 ?
603
+ " (versionable)" : "");
604
+ }
605
+ fossil_print("%s\n\n", blob_str(&txt));
606
+ blob_reset(&txt);
607
+ }
608
+ occHelp[aCommand[i].iHelp] = 0;
586609
}
587610
}
588611
if( useHtml ){
589612
fossil_print("<!-- end_all_help -->\n");
590613
}else{
@@ -601,17 +624,19 @@
601624
** Show help text for commands and pages. Useful for proof-reading.
602625
** Defaults to just the CLI commands. Specify --www to see only the
603626
** web pages, or --everything to see both commands and pages.
604627
**
605628
** Options:
606
-** -e|--everything Show all commands and pages.
629
+** -a|--aliases Show aliases.
630
+** -e|--everything Show all commands and pages. Omit aliases to
631
+** avoid duplicates.
632
+** -h|--html Transform output to HTML.
633
+** -o|--options Show global options.
634
+** -r|--raw No output formatting.
635
+** -s|--settings Show settings.
607636
** -t|--test Include test- commands.
608637
** -w|--www Show WWW pages.
609
-** -s|--settings Show settings.
610
-** -h|--html Transform output to HTML.
611
-** -r|--raw No output formatting.
612
-** -o|--options Show global options.
613638
*/
614639
void test_all_help_cmd(void){
615640
int mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER;
616641
int useHtml = find_option("html","h",0)!=0;
617642
int rawOut = find_option("raw","r",0)!=0;
@@ -619,15 +644,18 @@
619644
if( find_option("www","w",0) ){
620645
mask = CMDFLAG_WEBPAGE;
621646
}
622647
if( find_option("everything","e",0) ){
623648
mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER | CMDFLAG_WEBPAGE |
624
- CMDFLAG_SETTING | CMDFLAG_TEST;
649
+ CMDFLAG_ALIAS | CMDFLAG_SETTING | CMDFLAG_TEST;
625650
}
626651
if( find_option("settings","s",0) ){
627652
mask = CMDFLAG_SETTING;
628653
}
654
+ if( find_option("aliases","a",0) ){
655
+ mask = CMDFLAG_ALIAS;
656
+ }
629657
if( find_option("test","t",0) ){
630658
mask |= CMDFLAG_TEST;
631659
}
632660
display_all_help(mask, useHtml, rawOut);
633661
}
@@ -655,10 +683,12 @@
655683
countCmds( CMDFLAG_COMMAND ));
656684
fossil_print(" 1st tier %4d\n",
657685
countCmds( CMDFLAG_1ST_TIER ));
658686
fossil_print(" 2nd tier %4d\n",
659687
countCmds( CMDFLAG_2ND_TIER ));
688
+ fossil_print(" alias %4d\n",
689
+ countCmds( CMDFLAG_ALIAS ));
660690
fossil_print(" test %4d\n",
661691
countCmds( CMDFLAG_TEST ));
662692
fossil_print("web-pages: %4d\n",
663693
countCmds( CMDFLAG_WEBPAGE ));
664694
fossil_print("settings: %4d\n",
@@ -828,26 +858,56 @@
828858
@ </div>
829859
}
830860
}
831861
}else{
832862
int i;
833
-
863
+ unsigned char occHelp[FOSSIL_MX_CMDIDX] = {0}; /* Help str occurrences */
864
+ int bktHelp[FOSSIL_MX_CMDIDX][MX_HELP_DUP] = {0};/* Help str -> commands */
834865
style_header("Help");
835866
836867
@ <a name='commands'></a>
837868
@ <h1>Available commands:</h1>
838869
@ <div class="columns" style="column-width: 12ex;">
839870
@ <ul>
871
+ /* Fill in help string buckets */
872
+ for(i=0; i<MX_COMMAND; i++){
873
+ if(aCommand[i].eCmdFlags & CMDFLAG_HIDDEN) continue;
874
+ bktHelp[aCommand[i].iHelp][occHelp[aCommand[i].iHelp]++] = i;
875
+ }
840876
for(i=0; i<MX_COMMAND; i++){
841877
const char *z = aCommand[i].zName;
842878
const char *zBoldOn = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"<b>" :"";
843879
const char *zBoldOff = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"</b>":"";
844880
if( '/'==*z || strncmp(z,"test",4)==0 ) continue;
845881
if( (aCommand[i].eCmdFlags & CMDFLAG_SETTING)!=0 ) continue;
846882
else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
847
- @ <li><a href="%R/help?cmd=%s(z)">%s(zBoldOn)%s(z)%s(zBoldOff)</a></li>
883
+ else if( (aCommand[i].eCmdFlags & CMDFLAG_ALIAS)!=0 ) continue;
884
+ @ <li><a href="%R/help?cmd=%s(z)">%s(zBoldOn)%s(z)%s(zBoldOff)</a>
885
+ /* Output aliases */
886
+ if( occHelp[aCommand[i].iHelp] > 1 ){
887
+ int j;
888
+ int aliases[MX_HELP_DUP], nAliases=0;
889
+ for(j=0; j<occHelp[aCommand[i].iHelp]; j++){
890
+ if( bktHelp[aCommand[i].iHelp][j] != i ){
891
+ if( aCommand[bktHelp[aCommand[i].iHelp][j]].eCmdFlags & CMDFLAG_ALIAS ){
892
+ aliases[nAliases++] = bktHelp[aCommand[i].iHelp][j];
893
+ }
894
+ }
895
+ }
896
+ if( nAliases>0 ){
897
+ int k;
898
+ @(\
899
+ for(k=0; k<nAliases; k++){
900
+ @<a href="%R/help?cmd=%s(aCommand[aliases[k]].zName)">\
901
+ @%s(aCommand[aliases[k]].zName)</a>%s((k<nAliases-1)?", ":"")\
902
+ }
903
+ @)\
904
+ }
905
+ }
906
+ @ </li>
848907
}
908
+
849909
@ </ul></div>
850910
851911
@ <a name='webpages'></a>
852912
@ <h1>Available web UI pages:</h1>
853913
@ <div class="columns" style="column-width: 18ex;">
@@ -905,22 +965,31 @@
905965
**
906966
** Show all help text on a single page. Useful for proof-reading.
907967
*/
908968
void test_all_help_page(void){
909969
int i;
970
+ unsigned char occHelp[FOSSIL_MX_CMDIDX] = {0}; /* Help string occurrences */
971
+ int bktHelp[FOSSIL_MX_CMDIDX][MX_HELP_DUP] = {0};/* Help strings -> commands*/
910972
Blob buf;
911973
blob_init(&buf,0,0);
912974
style_set_current_feature("test");
913975
style_header("All Help Text");
914976
@ <dl>
977
+ /* Fill in help string buckets */
978
+ for(i=0; i<MX_COMMAND; i++){
979
+ if(aCommand[i].eCmdFlags & CMDFLAG_HIDDEN) continue;
980
+ bktHelp[aCommand[i].iHelp][occHelp[aCommand[i].iHelp]++] = i;
981
+ }
915982
for(i=0; i<MX_COMMAND; i++){
916983
const char *zDesc;
917984
unsigned int e = aCommand[i].eCmdFlags;
918985
if( e & CMDFLAG_1ST_TIER ){
919986
zDesc = "1st tier command";
920987
}else if( e & CMDFLAG_2ND_TIER ){
921988
zDesc = "2nd tier command";
989
+ }else if( e & CMDFLAG_ALIAS ){
990
+ zDesc = "alias";
922991
}else if( e & CMDFLAG_TEST ){
923992
zDesc = "test command";
924993
}else if( e & CMDFLAG_WEBPAGE ){
925994
if( e & CMDFLAG_RAWCONTENT ){
926995
zDesc = "raw-content web page";
@@ -940,14 +1009,38 @@
9401009
}
9411010
blob_appendf(&buf,"setting");
9421011
zDesc = blob_str(&buf);
9431012
}
9441013
if( memcmp(aCommand[i].zName, "test", 4)==0 ) continue;
945
- @ <dt><big><b>%s(aCommand[i].zName)</b></big> (%s(zDesc))</dt>
946
- @ <dd>
947
- help_to_html(aCommand[i].zHelp, cgi_output_blob());
948
- @ </dd>
1014
+ if( occHelp[aCommand[i].iHelp] > 0 ){
1015
+ int j;
1016
+ for(j=0; j<occHelp[aCommand[i].iHelp]; j++){
1017
+ unsigned int e = aCommand[bktHelp[aCommand[i].iHelp][j]].eCmdFlags;
1018
+ if( e & CMDFLAG_1ST_TIER ){
1019
+ zDesc = "1st tier command";
1020
+ }else if( e & CMDFLAG_2ND_TIER ){
1021
+ zDesc = "2nd tier command";
1022
+ }else if( e & CMDFLAG_ALIAS ){
1023
+ zDesc = "alias";
1024
+ }else if( e & CMDFLAG_TEST ){
1025
+ zDesc = "test command";
1026
+ }else if( e & CMDFLAG_WEBPAGE ){
1027
+ if( e & CMDFLAG_RAWCONTENT ){
1028
+ zDesc = "raw-content web page";
1029
+ }else{
1030
+ zDesc = "web page";
1031
+ }
1032
+ }
1033
+
1034
+ @ <dt><big><b>%s(aCommand[bktHelp[aCommand[i].iHelp][j]].zName)</b>
1035
+ @</big> (%s(zDesc))</dt>
1036
+ }
1037
+ @ <dd>
1038
+ help_to_html(aCommand[i].zHelp, cgi_output_blob());
1039
+ @ </dd>
1040
+ occHelp[aCommand[i].iHelp] = 0;
1041
+ }
9491042
}
9501043
@ </dl>
9511044
blob_reset(&buf);
9521045
style_finish_page();
9531046
}
9541047
--- src/dispatch.c
+++ src/dispatch.c
@@ -31,10 +31,11 @@
31 */
32 struct CmdOrPage {
33 const char *zName; /* Name. Webpages start with "/". Commands do not */
34 void (*xFunc)(void); /* Implementation function, or NULL for settings */
35 const char *zHelp; /* Raw help text */
 
36 unsigned int eCmdFlags; /* Flags */
37 };
38
39 /***************************************************************************
40 ** These macros must match similar macros in mkindex.c
@@ -51,10 +52,11 @@
51 #define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
52 #define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret POST content */
53 /* NOTE: 0x0400 = CMDFLAG_SENSITIVE in mkindex.c! */
54 #define CMDFLAG_HIDDEN 0x0800 /* Elide from most listings */
55 #define CMDFLAG_LDAVG_EXEMPT 0x1000 /* Exempt from load_control() */
 
56 /**************************************************************************/
57
58 /* Values for the 2nd parameter to dispatch_name_search() */
59 #define CMDFLAG_ANY 0x0038 /* Match anything */
60 #define CMDFLAG_PREFIX 0x0200 /* Prefix match is ok */
@@ -77,10 +79,11 @@
77 ** source code files looking for header comments on the functions that
78 ** implement command and webpages.
79 */
80 #include "page_index.h"
81 #define MX_COMMAND count(aCommand)
 
82
83 /*
84 ** Given a command, webpage, or setting name in zName, find the corresponding
85 ** CmdOrPage object and return a pointer to that object in *ppCmd.
86 **
@@ -546,45 +549,65 @@
546 /*
547 ** Display help for all commands based on provided flags.
548 */
549 static void display_all_help(int mask, int useHtml, int rawOut){
550 int i;
 
 
551 if( useHtml ) fossil_print("<!--\n");
552 fossil_print("Help text for:\n");
553 if( mask & CMDFLAG_1ST_TIER ) fossil_print(" * Commands\n");
554 if( mask & CMDFLAG_2ND_TIER ) fossil_print(" * Auxiliary commands\n");
 
555 if( mask & CMDFLAG_TEST ) fossil_print(" * Test commands\n");
556 if( mask & CMDFLAG_WEBPAGE ) fossil_print(" * Web pages\n");
557 if( mask & CMDFLAG_SETTING ) fossil_print(" * Settings\n");
558 if( useHtml ){
559 fossil_print("-->\n");
560 fossil_print("<!-- start_all_help -->\n");
561 }else{
562 fossil_print("---\n");
563 }
 
 
 
 
 
 
564 for(i=0; i<MX_COMMAND; i++){
565 if( (aCommand[i].eCmdFlags & mask)==0 ) continue;
566 else if(aCommand[i].eCmdFlags & CMDFLAG_HIDDEN) continue;
567 if( useHtml ){
568 Blob html;
569 blob_init(&html, 0, 0);
570 help_to_html(aCommand[i].zHelp, &html);
571 fossil_print("<h1>%h</h1>\n", aCommand[i].zName);
572 fossil_print("%s\n<hr>\n", blob_str(&html));
573 blob_reset(&html);
574 }else if( rawOut ){
575 fossil_print("# %s\n", aCommand[i].zName);
576 fossil_print("%s\n\n", aCommand[i].zHelp);
577 }else{
578 Blob txt;
579 blob_init(&txt, 0, 0);
580 help_to_text(aCommand[i].zHelp, &txt);
581 fossil_print("# %s%s\n", aCommand[i].zName,
582 (aCommand[i].eCmdFlags & CMDFLAG_VERSIONABLE)!=0 ?
583 " (versionable)" : "");
584 fossil_print("%s\n\n", blob_str(&txt));
585 blob_reset(&txt);
 
 
 
 
 
 
 
 
 
 
 
586 }
587 }
588 if( useHtml ){
589 fossil_print("<!-- end_all_help -->\n");
590 }else{
@@ -601,17 +624,19 @@
601 ** Show help text for commands and pages. Useful for proof-reading.
602 ** Defaults to just the CLI commands. Specify --www to see only the
603 ** web pages, or --everything to see both commands and pages.
604 **
605 ** Options:
606 ** -e|--everything Show all commands and pages.
 
 
 
 
 
 
607 ** -t|--test Include test- commands.
608 ** -w|--www Show WWW pages.
609 ** -s|--settings Show settings.
610 ** -h|--html Transform output to HTML.
611 ** -r|--raw No output formatting.
612 ** -o|--options Show global options.
613 */
614 void test_all_help_cmd(void){
615 int mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER;
616 int useHtml = find_option("html","h",0)!=0;
617 int rawOut = find_option("raw","r",0)!=0;
@@ -619,15 +644,18 @@
619 if( find_option("www","w",0) ){
620 mask = CMDFLAG_WEBPAGE;
621 }
622 if( find_option("everything","e",0) ){
623 mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER | CMDFLAG_WEBPAGE |
624 CMDFLAG_SETTING | CMDFLAG_TEST;
625 }
626 if( find_option("settings","s",0) ){
627 mask = CMDFLAG_SETTING;
628 }
 
 
 
629 if( find_option("test","t",0) ){
630 mask |= CMDFLAG_TEST;
631 }
632 display_all_help(mask, useHtml, rawOut);
633 }
@@ -655,10 +683,12 @@
655 countCmds( CMDFLAG_COMMAND ));
656 fossil_print(" 1st tier %4d\n",
657 countCmds( CMDFLAG_1ST_TIER ));
658 fossil_print(" 2nd tier %4d\n",
659 countCmds( CMDFLAG_2ND_TIER ));
 
 
660 fossil_print(" test %4d\n",
661 countCmds( CMDFLAG_TEST ));
662 fossil_print("web-pages: %4d\n",
663 countCmds( CMDFLAG_WEBPAGE ));
664 fossil_print("settings: %4d\n",
@@ -828,26 +858,56 @@
828 @ </div>
829 }
830 }
831 }else{
832 int i;
833
 
834 style_header("Help");
835
836 @ <a name='commands'></a>
837 @ <h1>Available commands:</h1>
838 @ <div class="columns" style="column-width: 12ex;">
839 @ <ul>
 
 
 
 
 
840 for(i=0; i<MX_COMMAND; i++){
841 const char *z = aCommand[i].zName;
842 const char *zBoldOn = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"<b>" :"";
843 const char *zBoldOff = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"</b>":"";
844 if( '/'==*z || strncmp(z,"test",4)==0 ) continue;
845 if( (aCommand[i].eCmdFlags & CMDFLAG_SETTING)!=0 ) continue;
846 else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
847 @ <li><a href="%R/help?cmd=%s(z)">%s(zBoldOn)%s(z)%s(zBoldOff)</a></li>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
848 }
 
849 @ </ul></div>
850
851 @ <a name='webpages'></a>
852 @ <h1>Available web UI pages:</h1>
853 @ <div class="columns" style="column-width: 18ex;">
@@ -905,22 +965,31 @@
905 **
906 ** Show all help text on a single page. Useful for proof-reading.
907 */
908 void test_all_help_page(void){
909 int i;
 
 
910 Blob buf;
911 blob_init(&buf,0,0);
912 style_set_current_feature("test");
913 style_header("All Help Text");
914 @ <dl>
 
 
 
 
 
915 for(i=0; i<MX_COMMAND; i++){
916 const char *zDesc;
917 unsigned int e = aCommand[i].eCmdFlags;
918 if( e & CMDFLAG_1ST_TIER ){
919 zDesc = "1st tier command";
920 }else if( e & CMDFLAG_2ND_TIER ){
921 zDesc = "2nd tier command";
 
 
922 }else if( e & CMDFLAG_TEST ){
923 zDesc = "test command";
924 }else if( e & CMDFLAG_WEBPAGE ){
925 if( e & CMDFLAG_RAWCONTENT ){
926 zDesc = "raw-content web page";
@@ -940,14 +1009,38 @@
940 }
941 blob_appendf(&buf,"setting");
942 zDesc = blob_str(&buf);
943 }
944 if( memcmp(aCommand[i].zName, "test", 4)==0 ) continue;
945 @ <dt><big><b>%s(aCommand[i].zName)</b></big> (%s(zDesc))</dt>
946 @ <dd>
947 help_to_html(aCommand[i].zHelp, cgi_output_blob());
948 @ </dd>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
949 }
950 @ </dl>
951 blob_reset(&buf);
952 style_finish_page();
953 }
954
--- src/dispatch.c
+++ src/dispatch.c
@@ -31,10 +31,11 @@
31 */
32 struct CmdOrPage {
33 const char *zName; /* Name. Webpages start with "/". Commands do not */
34 void (*xFunc)(void); /* Implementation function, or NULL for settings */
35 const char *zHelp; /* Raw help text */
36 int iHelp; /* Index of help variable */
37 unsigned int eCmdFlags; /* Flags */
38 };
39
40 /***************************************************************************
41 ** These macros must match similar macros in mkindex.c
@@ -51,10 +52,11 @@
52 #define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
53 #define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret POST content */
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 /**************************************************************************/
59
60 /* Values for the 2nd parameter to dispatch_name_search() */
61 #define CMDFLAG_ANY 0x0038 /* Match anything */
62 #define CMDFLAG_PREFIX 0x0200 /* Prefix match is ok */
@@ -77,10 +79,11 @@
79 ** source code files looking for header comments on the functions that
80 ** implement command and webpages.
81 */
82 #include "page_index.h"
83 #define MX_COMMAND count(aCommand)
84 #define MX_HELP_DUP 5 /* Upper bound estimate on help string duplication */
85
86 /*
87 ** Given a command, webpage, or setting name in zName, find the corresponding
88 ** CmdOrPage object and return a pointer to that object in *ppCmd.
89 **
@@ -546,45 +549,65 @@
549 /*
550 ** Display help for all commands based on provided flags.
551 */
552 static void display_all_help(int mask, int useHtml, int rawOut){
553 int i;
554 unsigned char occHelp[FOSSIL_MX_CMDIDX] = {0}; /* Help string occurrences */
555 int bktHelp[FOSSIL_MX_CMDIDX][MX_HELP_DUP] = {0};/* Help strings -> commands*/
556 if( useHtml ) fossil_print("<!--\n");
557 fossil_print("Help text for:\n");
558 if( mask & CMDFLAG_1ST_TIER ) fossil_print(" * Commands\n");
559 if( mask & CMDFLAG_2ND_TIER ) fossil_print(" * Auxiliary commands\n");
560 if( mask & CMDFLAG_ALIAS ) fossil_print(" * Aliases\n");
561 if( mask & CMDFLAG_TEST ) fossil_print(" * Test commands\n");
562 if( mask & CMDFLAG_WEBPAGE ) fossil_print(" * Web pages\n");
563 if( mask & CMDFLAG_SETTING ) fossil_print(" * Settings\n");
564 if( useHtml ){
565 fossil_print("-->\n");
566 fossil_print("<!-- start_all_help -->\n");
567 }else{
568 fossil_print("---\n");
569 }
570 /* Fill in help string buckets */
571 for(i=0; i<MX_COMMAND; i++){
572 if( (aCommand[i].eCmdFlags & mask)==0 ) continue;
573 else if(aCommand[i].eCmdFlags & CMDFLAG_HIDDEN) continue;
574 bktHelp[aCommand[i].iHelp][occHelp[aCommand[i].iHelp]++] = i;
575 }
576 for(i=0; i<MX_COMMAND; i++){
577 if( (aCommand[i].eCmdFlags & mask)==0 ) continue;
578 else if(aCommand[i].eCmdFlags & CMDFLAG_HIDDEN) continue;
579 if( occHelp[aCommand[i].iHelp] > 0 ){
580 int j;
581 if( useHtml ){
582 Blob html;
583 blob_init(&html, 0, 0);
584 help_to_html(aCommand[i].zHelp, &html);
585 for(j=0; j<occHelp[aCommand[i].iHelp]; j++){
586 fossil_print("<h1>%h</h1>\n",
587 aCommand[bktHelp[aCommand[i].iHelp][j]].zName);
588 }
589 fossil_print("%s\n<hr>\n", blob_str(&html));
590 blob_reset(&html);
591 }else if( rawOut ){
592 for(j=0; j<occHelp[aCommand[i].iHelp]; j++)
593 fossil_print("# %s\n", aCommand[bktHelp[aCommand[i].iHelp][j]].zName);
594 fossil_print("%s\n\n", aCommand[i].zHelp);
595 }else{
596 Blob txt;
597 blob_init(&txt, 0, 0);
598 help_to_text(aCommand[i].zHelp, &txt);
599 for(j=0; j<occHelp[aCommand[i].iHelp]; j++){
600 fossil_print("# %s%s\n",
601 aCommand[bktHelp[aCommand[i].iHelp][j]].zName,
602 (aCommand[i].eCmdFlags & CMDFLAG_VERSIONABLE)!=0 ?
603 " (versionable)" : "");
604 }
605 fossil_print("%s\n\n", blob_str(&txt));
606 blob_reset(&txt);
607 }
608 occHelp[aCommand[i].iHelp] = 0;
609 }
610 }
611 if( useHtml ){
612 fossil_print("<!-- end_all_help -->\n");
613 }else{
@@ -601,17 +624,19 @@
624 ** Show help text for commands and pages. Useful for proof-reading.
625 ** Defaults to just the CLI commands. Specify --www to see only the
626 ** web pages, or --everything to see both commands and pages.
627 **
628 ** Options:
629 ** -a|--aliases Show aliases.
630 ** -e|--everything Show all commands and pages. Omit aliases to
631 ** avoid duplicates.
632 ** -h|--html Transform output to HTML.
633 ** -o|--options Show global options.
634 ** -r|--raw No output formatting.
635 ** -s|--settings Show settings.
636 ** -t|--test Include test- commands.
637 ** -w|--www Show WWW pages.
 
 
 
 
638 */
639 void test_all_help_cmd(void){
640 int mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER;
641 int useHtml = find_option("html","h",0)!=0;
642 int rawOut = find_option("raw","r",0)!=0;
@@ -619,15 +644,18 @@
644 if( find_option("www","w",0) ){
645 mask = CMDFLAG_WEBPAGE;
646 }
647 if( find_option("everything","e",0) ){
648 mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER | CMDFLAG_WEBPAGE |
649 CMDFLAG_ALIAS | CMDFLAG_SETTING | CMDFLAG_TEST;
650 }
651 if( find_option("settings","s",0) ){
652 mask = CMDFLAG_SETTING;
653 }
654 if( find_option("aliases","a",0) ){
655 mask = CMDFLAG_ALIAS;
656 }
657 if( find_option("test","t",0) ){
658 mask |= CMDFLAG_TEST;
659 }
660 display_all_help(mask, useHtml, rawOut);
661 }
@@ -655,10 +683,12 @@
683 countCmds( CMDFLAG_COMMAND ));
684 fossil_print(" 1st tier %4d\n",
685 countCmds( CMDFLAG_1ST_TIER ));
686 fossil_print(" 2nd tier %4d\n",
687 countCmds( CMDFLAG_2ND_TIER ));
688 fossil_print(" alias %4d\n",
689 countCmds( CMDFLAG_ALIAS ));
690 fossil_print(" test %4d\n",
691 countCmds( CMDFLAG_TEST ));
692 fossil_print("web-pages: %4d\n",
693 countCmds( CMDFLAG_WEBPAGE ));
694 fossil_print("settings: %4d\n",
@@ -828,26 +858,56 @@
858 @ </div>
859 }
860 }
861 }else{
862 int i;
863 unsigned char occHelp[FOSSIL_MX_CMDIDX] = {0}; /* Help str occurrences */
864 int bktHelp[FOSSIL_MX_CMDIDX][MX_HELP_DUP] = {0};/* Help str -> commands */
865 style_header("Help");
866
867 @ <a name='commands'></a>
868 @ <h1>Available commands:</h1>
869 @ <div class="columns" style="column-width: 12ex;">
870 @ <ul>
871 /* Fill in help string buckets */
872 for(i=0; i<MX_COMMAND; i++){
873 if(aCommand[i].eCmdFlags & CMDFLAG_HIDDEN) continue;
874 bktHelp[aCommand[i].iHelp][occHelp[aCommand[i].iHelp]++] = i;
875 }
876 for(i=0; i<MX_COMMAND; i++){
877 const char *z = aCommand[i].zName;
878 const char *zBoldOn = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"<b>" :"";
879 const char *zBoldOff = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"</b>":"";
880 if( '/'==*z || strncmp(z,"test",4)==0 ) continue;
881 if( (aCommand[i].eCmdFlags & CMDFLAG_SETTING)!=0 ) continue;
882 else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
883 else if( (aCommand[i].eCmdFlags & CMDFLAG_ALIAS)!=0 ) continue;
884 @ <li><a href="%R/help?cmd=%s(z)">%s(zBoldOn)%s(z)%s(zBoldOff)</a>
885 /* Output aliases */
886 if( occHelp[aCommand[i].iHelp] > 1 ){
887 int j;
888 int aliases[MX_HELP_DUP], nAliases=0;
889 for(j=0; j<occHelp[aCommand[i].iHelp]; j++){
890 if( bktHelp[aCommand[i].iHelp][j] != i ){
891 if( aCommand[bktHelp[aCommand[i].iHelp][j]].eCmdFlags & CMDFLAG_ALIAS ){
892 aliases[nAliases++] = bktHelp[aCommand[i].iHelp][j];
893 }
894 }
895 }
896 if( nAliases>0 ){
897 int k;
898 @(\
899 for(k=0; k<nAliases; k++){
900 @<a href="%R/help?cmd=%s(aCommand[aliases[k]].zName)">\
901 @%s(aCommand[aliases[k]].zName)</a>%s((k<nAliases-1)?", ":"")\
902 }
903 @)\
904 }
905 }
906 @ </li>
907 }
908
909 @ </ul></div>
910
911 @ <a name='webpages'></a>
912 @ <h1>Available web UI pages:</h1>
913 @ <div class="columns" style="column-width: 18ex;">
@@ -905,22 +965,31 @@
965 **
966 ** Show all help text on a single page. Useful for proof-reading.
967 */
968 void test_all_help_page(void){
969 int i;
970 unsigned char occHelp[FOSSIL_MX_CMDIDX] = {0}; /* Help string occurrences */
971 int bktHelp[FOSSIL_MX_CMDIDX][MX_HELP_DUP] = {0};/* Help strings -> commands*/
972 Blob buf;
973 blob_init(&buf,0,0);
974 style_set_current_feature("test");
975 style_header("All Help Text");
976 @ <dl>
977 /* Fill in help string buckets */
978 for(i=0; i<MX_COMMAND; i++){
979 if(aCommand[i].eCmdFlags & CMDFLAG_HIDDEN) continue;
980 bktHelp[aCommand[i].iHelp][occHelp[aCommand[i].iHelp]++] = i;
981 }
982 for(i=0; i<MX_COMMAND; i++){
983 const char *zDesc;
984 unsigned int e = aCommand[i].eCmdFlags;
985 if( e & CMDFLAG_1ST_TIER ){
986 zDesc = "1st tier command";
987 }else if( e & CMDFLAG_2ND_TIER ){
988 zDesc = "2nd tier command";
989 }else if( e & CMDFLAG_ALIAS ){
990 zDesc = "alias";
991 }else if( e & CMDFLAG_TEST ){
992 zDesc = "test command";
993 }else if( e & CMDFLAG_WEBPAGE ){
994 if( e & CMDFLAG_RAWCONTENT ){
995 zDesc = "raw-content web page";
@@ -940,14 +1009,38 @@
1009 }
1010 blob_appendf(&buf,"setting");
1011 zDesc = blob_str(&buf);
1012 }
1013 if( memcmp(aCommand[i].zName, "test", 4)==0 ) continue;
1014 if( occHelp[aCommand[i].iHelp] > 0 ){
1015 int j;
1016 for(j=0; j<occHelp[aCommand[i].iHelp]; j++){
1017 unsigned int e = aCommand[bktHelp[aCommand[i].iHelp][j]].eCmdFlags;
1018 if( e & CMDFLAG_1ST_TIER ){
1019 zDesc = "1st tier command";
1020 }else if( e & CMDFLAG_2ND_TIER ){
1021 zDesc = "2nd tier command";
1022 }else if( e & CMDFLAG_ALIAS ){
1023 zDesc = "alias";
1024 }else if( e & CMDFLAG_TEST ){
1025 zDesc = "test command";
1026 }else if( e & CMDFLAG_WEBPAGE ){
1027 if( e & CMDFLAG_RAWCONTENT ){
1028 zDesc = "raw-content web page";
1029 }else{
1030 zDesc = "web page";
1031 }
1032 }
1033
1034 @ <dt><big><b>%s(aCommand[bktHelp[aCommand[i].iHelp][j]].zName)</b>
1035 @</big> (%s(zDesc))</dt>
1036 }
1037 @ <dd>
1038 help_to_html(aCommand[i].zHelp, cgi_output_blob());
1039 @ </dd>
1040 occHelp[aCommand[i].iHelp] = 0;
1041 }
1042 }
1043 @ </dl>
1044 blob_reset(&buf);
1045 style_finish_page();
1046 }
1047
--- src/unversioned.c
+++ src/unversioned.c
@@ -218,11 +218,11 @@
218218
}
219219
return 0;
220220
}
221221
222222
/*
223
-** COMMAND: uv*
223
+** COMMAND: uv#
224224
** COMMAND: unversioned
225225
**
226226
** Usage: %fossil unversioned SUBCOMMAND ARGS...
227227
** or: %fossil uv SUBCOMMAND ARGS..
228228
**
229229
--- src/unversioned.c
+++ src/unversioned.c
@@ -218,11 +218,11 @@
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
--- src/unversioned.c
+++ src/unversioned.c
@@ -218,11 +218,11 @@
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
+20 -5
--- tools/mkindex.c
+++ tools/mkindex.c
@@ -37,14 +37,18 @@
3737
** and analysis only.
3838
**
3939
** Commands are 1st-tier by default. If the command name begins with
4040
** "test-" or if the command name has a "test" argument, then it becomes
4141
** a test command. If the command name has a "2nd-tier" argument or ends
42
-** with a "*" character, it is second tier. Examples:
42
+** with a "*" character, it is second tier. If the command name has an "alias"
43
+** argument or ends with a "#" character, it is an alias: another name
44
+** (a one-to-one replacement) for a command. Examples:
4345
**
4446
** COMMAND: abcde*
4547
** COMMAND: fghij 2nd-tier
48
+** COMMAND: mnopq#
49
+** COMMAND: rstuv alias
4650
** COMMAND: test-xyzzy
4751
** COMMAND: xyzzy test
4852
**
4953
** A SETTING: may be followed by arguments that give additional attributes
5054
** to that setting:
@@ -93,10 +97,11 @@
9397
#define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
9498
#define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret webpage content */
9599
#define CMDFLAG_SENSITIVE 0x0400 /* Security-sensitive setting */
96100
#define CMDFLAG_HIDDEN 0x0800 /* Elide from most listings */
97101
#define CMDFLAG_LDAVG_EXEMPT 0x1000 /* Exempt from load_control() */
102
+#define CMDFLAG_ALIAS 0x2000 /* Command aliases */
98103
/**************************************************************************/
99104
100105
/*
101106
** Each entry looks like this:
102107
*/
@@ -219,10 +224,15 @@
219224
}else if( zLine[i+j-1]=='*' ){
220225
/* If the command name ends in '*', remove the '*' from the name
221226
** but move the command into the second tier */
222227
aEntry[nUsed].zPath[j-1] = 0;
223228
aEntry[nUsed].eType |= CMDFLAG_2ND_TIER;
229
+ }else if( zLine[i+j-1]=='#' ){
230
+ /* If the command name ends in '#', remove the '#' from the name
231
+ ** but move the command into aliases */
232
+ aEntry[nUsed].zPath[j-1] = 0;
233
+ aEntry[nUsed].eType |= CMDFLAG_ALIAS;
224234
}else{
225235
/* Otherwise, this is a first-tier command */
226236
aEntry[nUsed].eType |= CMDFLAG_1ST_TIER;
227237
}
228238
}
@@ -232,18 +242,21 @@
232242
i += j;
233243
while( fossil_isspace(zLine[i]) ){ i++; }
234244
if( zLine[i]==0 ) break;
235245
for(j=0; zLine[i+j] && !fossil_isspace(zLine[i+j]); j++){}
236246
if( j==8 && strncmp(&zLine[i], "1st-tier", j)==0 ){
237
- aEntry[nUsed].eType &= ~(CMDFLAG_2ND_TIER|CMDFLAG_TEST);
247
+ aEntry[nUsed].eType &= ~(CMDFLAG_2ND_TIER|CMDFLAG_TEST|CMDFLAG_ALIAS);
238248
aEntry[nUsed].eType |= CMDFLAG_1ST_TIER;
239249
}else if( j==8 && strncmp(&zLine[i], "2nd-tier", j)==0 ){
240
- aEntry[nUsed].eType &= ~(CMDFLAG_1ST_TIER|CMDFLAG_TEST);
250
+ aEntry[nUsed].eType &= ~(CMDFLAG_1ST_TIER|CMDFLAG_TEST|CMDFLAG_ALIAS);
241251
aEntry[nUsed].eType |= CMDFLAG_2ND_TIER;
242252
}else if( j==4 && strncmp(&zLine[i], "test", j)==0 ){
243
- aEntry[nUsed].eType &= ~(CMDFLAG_1ST_TIER|CMDFLAG_2ND_TIER);
253
+ aEntry[nUsed].eType &= ~(CMDFLAG_1ST_TIER|CMDFLAG_2ND_TIER|CMDFLAG_ALIAS);
244254
aEntry[nUsed].eType |= CMDFLAG_TEST;
255
+ }else if( j==5 && strncmp(&zLine[i], "alias", j)==0 ){
256
+ aEntry[nUsed].eType &= ~(CMDFLAG_1ST_TIER|CMDFLAG_2ND_TIER|CMDFLAG_TEST);
257
+ aEntry[nUsed].eType |= CMDFLAG_ALIAS;
245258
}else if( j==11 && strncmp(&zLine[i], "raw-content", j)==0 ){
246259
aEntry[nUsed].eType |= CMDFLAG_RAWCONTENT;
247260
}else if( j==7 && strncmp(&zLine[i], "boolean", j)==0 ){
248261
aEntry[nUsed].eType &= ~(CMDFLAG_BLOCKTEXT);
249262
aEntry[nUsed].iWidth = 0;
@@ -453,24 +466,26 @@
453466
if( aEntry[i].zIf ){
454467
printf("%s", aEntry[i].zIf);
455468
}else if( (aEntry[i].eType & CMDFLAG_WEBPAGE)!=0 ){
456469
nWeb++;
457470
}
458
- printf(" { \"%.*s\",%*s%s,%*szHelp%03d, 0x%03x },\n",
471
+ printf(" { \"%.*s\",%*s%s,%*szHelp%03d, %3d, 0x%03x },\n",
459472
n, z,
460473
25-n, "",
461474
aEntry[i].zFunc,
462475
(int)(29-strlen(aEntry[i].zFunc)), "",
476
+ aEntry[i].iHelp,
463477
aEntry[i].iHelp,
464478
aEntry[i].eType
465479
);
466480
if( aEntry[i].zIf ) printf("#endif\n");
467481
}
468482
printf("};\n");
469483
printf("#define FOSSIL_FIRST_CMD %d\n", nWeb);
470484
printf("#define FOSSIL_MX_CMDNAME %d /* max length of any command name */\n",
471485
mxLen);
486
+ printf("#define FOSSIL_MX_CMDIDX %d /* max index for commands */\n", nFixed);
472487
473488
/* Generate the aSetting[] table */
474489
printf("const Setting aSetting[] = {\n");
475490
for(i=0; i<nFixed; i++){
476491
const char *z;
477492
--- tools/mkindex.c
+++ tools/mkindex.c
@@ -37,14 +37,18 @@
37 ** and analysis only.
38 **
39 ** Commands are 1st-tier by default. If the command name begins with
40 ** "test-" or if the command name has a "test" argument, then it becomes
41 ** a test command. If the command name has a "2nd-tier" argument or ends
42 ** with a "*" character, it is second tier. Examples:
 
 
43 **
44 ** COMMAND: abcde*
45 ** COMMAND: fghij 2nd-tier
 
 
46 ** COMMAND: test-xyzzy
47 ** COMMAND: xyzzy test
48 **
49 ** A SETTING: may be followed by arguments that give additional attributes
50 ** to that setting:
@@ -93,10 +97,11 @@
93 #define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
94 #define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret webpage content */
95 #define CMDFLAG_SENSITIVE 0x0400 /* Security-sensitive setting */
96 #define CMDFLAG_HIDDEN 0x0800 /* Elide from most listings */
97 #define CMDFLAG_LDAVG_EXEMPT 0x1000 /* Exempt from load_control() */
 
98 /**************************************************************************/
99
100 /*
101 ** Each entry looks like this:
102 */
@@ -219,10 +224,15 @@
219 }else if( zLine[i+j-1]=='*' ){
220 /* If the command name ends in '*', remove the '*' from the name
221 ** but move the command into the second tier */
222 aEntry[nUsed].zPath[j-1] = 0;
223 aEntry[nUsed].eType |= CMDFLAG_2ND_TIER;
 
 
 
 
 
224 }else{
225 /* Otherwise, this is a first-tier command */
226 aEntry[nUsed].eType |= CMDFLAG_1ST_TIER;
227 }
228 }
@@ -232,18 +242,21 @@
232 i += j;
233 while( fossil_isspace(zLine[i]) ){ i++; }
234 if( zLine[i]==0 ) break;
235 for(j=0; zLine[i+j] && !fossil_isspace(zLine[i+j]); j++){}
236 if( j==8 && strncmp(&zLine[i], "1st-tier", j)==0 ){
237 aEntry[nUsed].eType &= ~(CMDFLAG_2ND_TIER|CMDFLAG_TEST);
238 aEntry[nUsed].eType |= CMDFLAG_1ST_TIER;
239 }else if( j==8 && strncmp(&zLine[i], "2nd-tier", j)==0 ){
240 aEntry[nUsed].eType &= ~(CMDFLAG_1ST_TIER|CMDFLAG_TEST);
241 aEntry[nUsed].eType |= CMDFLAG_2ND_TIER;
242 }else if( j==4 && strncmp(&zLine[i], "test", j)==0 ){
243 aEntry[nUsed].eType &= ~(CMDFLAG_1ST_TIER|CMDFLAG_2ND_TIER);
244 aEntry[nUsed].eType |= CMDFLAG_TEST;
 
 
 
245 }else if( j==11 && strncmp(&zLine[i], "raw-content", j)==0 ){
246 aEntry[nUsed].eType |= CMDFLAG_RAWCONTENT;
247 }else if( j==7 && strncmp(&zLine[i], "boolean", j)==0 ){
248 aEntry[nUsed].eType &= ~(CMDFLAG_BLOCKTEXT);
249 aEntry[nUsed].iWidth = 0;
@@ -453,24 +466,26 @@
453 if( aEntry[i].zIf ){
454 printf("%s", aEntry[i].zIf);
455 }else if( (aEntry[i].eType & CMDFLAG_WEBPAGE)!=0 ){
456 nWeb++;
457 }
458 printf(" { \"%.*s\",%*s%s,%*szHelp%03d, 0x%03x },\n",
459 n, z,
460 25-n, "",
461 aEntry[i].zFunc,
462 (int)(29-strlen(aEntry[i].zFunc)), "",
 
463 aEntry[i].iHelp,
464 aEntry[i].eType
465 );
466 if( aEntry[i].zIf ) printf("#endif\n");
467 }
468 printf("};\n");
469 printf("#define FOSSIL_FIRST_CMD %d\n", nWeb);
470 printf("#define FOSSIL_MX_CMDNAME %d /* max length of any command name */\n",
471 mxLen);
 
472
473 /* Generate the aSetting[] table */
474 printf("const Setting aSetting[] = {\n");
475 for(i=0; i<nFixed; i++){
476 const char *z;
477
--- tools/mkindex.c
+++ tools/mkindex.c
@@ -37,14 +37,18 @@
37 ** and analysis only.
38 **
39 ** Commands are 1st-tier by default. If the command name begins with
40 ** "test-" or if the command name has a "test" argument, then it becomes
41 ** a test command. If the command name has a "2nd-tier" argument or ends
42 ** with a "*" character, it is second tier. If the command name has an "alias"
43 ** argument or ends with a "#" character, it is an alias: another name
44 ** (a one-to-one replacement) for a command. Examples:
45 **
46 ** COMMAND: abcde*
47 ** COMMAND: fghij 2nd-tier
48 ** COMMAND: mnopq#
49 ** COMMAND: rstuv alias
50 ** COMMAND: test-xyzzy
51 ** COMMAND: xyzzy test
52 **
53 ** A SETTING: may be followed by arguments that give additional attributes
54 ** to that setting:
@@ -93,10 +97,11 @@
97 #define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
98 #define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret webpage content */
99 #define CMDFLAG_SENSITIVE 0x0400 /* Security-sensitive setting */
100 #define CMDFLAG_HIDDEN 0x0800 /* Elide from most listings */
101 #define CMDFLAG_LDAVG_EXEMPT 0x1000 /* Exempt from load_control() */
102 #define CMDFLAG_ALIAS 0x2000 /* Command aliases */
103 /**************************************************************************/
104
105 /*
106 ** Each entry looks like this:
107 */
@@ -219,10 +224,15 @@
224 }else if( zLine[i+j-1]=='*' ){
225 /* If the command name ends in '*', remove the '*' from the name
226 ** but move the command into the second tier */
227 aEntry[nUsed].zPath[j-1] = 0;
228 aEntry[nUsed].eType |= CMDFLAG_2ND_TIER;
229 }else if( zLine[i+j-1]=='#' ){
230 /* If the command name ends in '#', remove the '#' from the name
231 ** but move the command into aliases */
232 aEntry[nUsed].zPath[j-1] = 0;
233 aEntry[nUsed].eType |= CMDFLAG_ALIAS;
234 }else{
235 /* Otherwise, this is a first-tier command */
236 aEntry[nUsed].eType |= CMDFLAG_1ST_TIER;
237 }
238 }
@@ -232,18 +242,21 @@
242 i += j;
243 while( fossil_isspace(zLine[i]) ){ i++; }
244 if( zLine[i]==0 ) break;
245 for(j=0; zLine[i+j] && !fossil_isspace(zLine[i+j]); j++){}
246 if( j==8 && strncmp(&zLine[i], "1st-tier", j)==0 ){
247 aEntry[nUsed].eType &= ~(CMDFLAG_2ND_TIER|CMDFLAG_TEST|CMDFLAG_ALIAS);
248 aEntry[nUsed].eType |= CMDFLAG_1ST_TIER;
249 }else if( j==8 && strncmp(&zLine[i], "2nd-tier", j)==0 ){
250 aEntry[nUsed].eType &= ~(CMDFLAG_1ST_TIER|CMDFLAG_TEST|CMDFLAG_ALIAS);
251 aEntry[nUsed].eType |= CMDFLAG_2ND_TIER;
252 }else if( j==4 && strncmp(&zLine[i], "test", j)==0 ){
253 aEntry[nUsed].eType &= ~(CMDFLAG_1ST_TIER|CMDFLAG_2ND_TIER|CMDFLAG_ALIAS);
254 aEntry[nUsed].eType |= CMDFLAG_TEST;
255 }else if( j==5 && strncmp(&zLine[i], "alias", j)==0 ){
256 aEntry[nUsed].eType &= ~(CMDFLAG_1ST_TIER|CMDFLAG_2ND_TIER|CMDFLAG_TEST);
257 aEntry[nUsed].eType |= CMDFLAG_ALIAS;
258 }else if( j==11 && strncmp(&zLine[i], "raw-content", j)==0 ){
259 aEntry[nUsed].eType |= CMDFLAG_RAWCONTENT;
260 }else if( j==7 && strncmp(&zLine[i], "boolean", j)==0 ){
261 aEntry[nUsed].eType &= ~(CMDFLAG_BLOCKTEXT);
262 aEntry[nUsed].iWidth = 0;
@@ -453,24 +466,26 @@
466 if( aEntry[i].zIf ){
467 printf("%s", aEntry[i].zIf);
468 }else if( (aEntry[i].eType & CMDFLAG_WEBPAGE)!=0 ){
469 nWeb++;
470 }
471 printf(" { \"%.*s\",%*s%s,%*szHelp%03d, %3d, 0x%03x },\n",
472 n, z,
473 25-n, "",
474 aEntry[i].zFunc,
475 (int)(29-strlen(aEntry[i].zFunc)), "",
476 aEntry[i].iHelp,
477 aEntry[i].iHelp,
478 aEntry[i].eType
479 );
480 if( aEntry[i].zIf ) printf("#endif\n");
481 }
482 printf("};\n");
483 printf("#define FOSSIL_FIRST_CMD %d\n", nWeb);
484 printf("#define FOSSIL_MX_CMDNAME %d /* max length of any command name */\n",
485 mxLen);
486 printf("#define FOSSIL_MX_CMDIDX %d /* max index for commands */\n", nFixed);
487
488 /* Generate the aSetting[] table */
489 printf("const Setting aSetting[] = {\n");
490 for(i=0; i<nFixed; i++){
491 const char *z;
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