Fossil SCM

Add a new category of help: help-topics. There is initially just one named "options" which explains the command-line options available for all commands. Other topics can now be easily added simply by inserting the appropriate "TOPIC:" comments into the code.

drh 2025-12-27 14:42 trunk
Commit 6eeb27aab94406bfd0b16692e92060f42b829d5926417d6044860b12ec033e76
2 files changed +109 -70 +61 -23
+109 -70
--- src/dispatch.c
+++ src/dispatch.c
@@ -25,11 +25,11 @@
2525
#include "dispatch.h"
2626
2727
#if INTERFACE
2828
/*
2929
** An instance of this object defines everything we need to know about an
30
-** individual command, webpage, or setting.
30
+** individual command, webpage, setting, or help topic.
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 */
@@ -39,31 +39,32 @@
3939
4040
/***************************************************************************
4141
** These macros must match similar macros in mkindex.c
4242
** Allowed values for CmdOrPage.eCmdFlags.
4343
*/
44
-#define CMDFLAG_1ST_TIER 0x0001 /* Most important commands */
45
-#define CMDFLAG_2ND_TIER 0x0002 /* Obscure and seldom used commands */
46
-#define CMDFLAG_TEST 0x0004 /* Commands for testing only */
47
-#define CMDFLAG_WEBPAGE 0x0008 /* Web pages */
48
-#define CMDFLAG_COMMAND 0x0010 /* A command */
49
-#define CMDFLAG_SETTING 0x0020 /* A setting */
50
-#define CMDFLAG_VERSIONABLE 0x0040 /* A versionable setting */
51
-#define CMDFLAG_BLOCKTEXT 0x0080 /* Multi-line text setting */
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
-#define CMDFLAG_KEEPEMPTY 0x4000 /* Do not unset empty settings */
59
-#define CMDFLAG_ABBREVSUBCMD 0x8000 /* Help text abbreviates subcommands */
44
+#define CMDFLAG_1ST_TIER 0x000001 /* Most important commands */
45
+#define CMDFLAG_2ND_TIER 0x000002 /* Obscure and seldom used commands */
46
+#define CMDFLAG_TEST 0x000004 /* Commands for testing only */
47
+#define CMDFLAG_WEBPAGE 0x000008 /* Web pages */
48
+#define CMDFLAG_COMMAND 0x000010 /* A command */
49
+#define CMDFLAG_SETTING 0x000020 /* A setting */
50
+#define CMDFLAG_VERSIONABLE 0x000040 /* A versionable setting */
51
+#define CMDFLAG_BLOCKTEXT 0x000080 /* Multi-line text setting */
52
+#define CMDFLAG_BOOLEAN 0x000100 /* A boolean setting */
53
+#define CMDFLAG_RAWCONTENT 0x000200 /* Do not interpret POST content */
54
+/* NOTE: 0x000400 = CMDFLAG_SENSITIVE in mkindex.c! */
55
+#define CMDFLAG_HIDDEN 0x000800 /* Elide from most listings */
56
+#define CMDFLAG_LDAVG_EXEMPT 0x001000 /* Exempt from load_control() */
57
+#define CMDFLAG_ALIAS 0x002000 /* Command aliases */
58
+#define CMDFLAG_KEEPEMPTY 0x004000 /* Do not unset empty settings */
59
+#define CMDFLAG_ABBREVSUBCMD 0x008000 /* Help text abbreviates subcommands */
60
+#define CMDFLAG_TOPIC 0x010000 /* A help topic */
6061
/**************************************************************************/
6162
6263
/* 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 */
64
+#define CMDFLAG_ANY 0x010038 /* Match anything */
65
+#define CMDFLAG_PREFIX 0x000200 /* Prefix match is OK */
6566
6667
#endif /* INTERFACE */
6768
6869
/*
6970
** The page_index.h file contains the definition for aCommand[] - an array
@@ -578,10 +579,11 @@
578579
if( mask & CMDFLAG_2ND_TIER ) fossil_print(" * Auxiliary commands\n");
579580
if( mask & CMDFLAG_ALIAS ) fossil_print(" * Aliases\n");
580581
if( mask & CMDFLAG_TEST ) fossil_print(" * Test commands\n");
581582
if( mask & CMDFLAG_WEBPAGE ) fossil_print(" * Web pages\n");
582583
if( mask & CMDFLAG_SETTING ) fossil_print(" * Settings\n");
584
+ if( mask & CMDFLAG_TOPIC ) fossil_print(" * Help Topic\n");
583585
if( useHtml ){
584586
fossil_print("-->\n");
585587
fossil_print("<!-- start_all_help -->\n");
586588
}else{
587589
fossil_print("---\n");
@@ -644,10 +646,11 @@
644646
** Defaults to just the CLI commands. Specify --www to see only the
645647
** web pages, or --everything to see both commands and pages.
646648
**
647649
** Options:
648650
** -a|--aliases Show aliases
651
+** -c|--topics Show help topics
649652
** -e|--everything Show all commands and pages. Omit aliases to
650653
** avoid duplicates.
651654
** -h|--html Transform output to HTML
652655
** -o|--options Show global options
653656
** -r|--raw No output formatting
@@ -663,20 +666,23 @@
663666
if( find_option("www","w",0) ){
664667
mask = CMDFLAG_WEBPAGE;
665668
}
666669
if( find_option("everything","e",0) ){
667670
mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER | CMDFLAG_WEBPAGE |
668
- CMDFLAG_ALIAS | CMDFLAG_SETTING | CMDFLAG_TEST;
671
+ CMDFLAG_ALIAS | CMDFLAG_SETTING | CMDFLAG_TEST | CMDFLAG_TOPIC;
669672
}
670673
if( find_option("settings","s",0) ){
671674
mask = CMDFLAG_SETTING;
672675
}
673676
if( find_option("aliases","a",0) ){
674677
mask = CMDFLAG_ALIAS;
675678
}
676679
if( find_option("test","t",0) ){
677680
mask |= CMDFLAG_TEST;
681
+ }
682
+ if( find_option("topics","c",0) ){
683
+ mask |= CMDFLAG_TOPIC;
678684
}
679685
display_all_help(mask, useHtml, rawOut);
680686
}
681687
682688
/*
@@ -710,10 +716,12 @@
710716
countCmds( CMDFLAG_TEST ));
711717
fossil_print("web-pages: %4d\n",
712718
countCmds( CMDFLAG_WEBPAGE ));
713719
fossil_print("settings: %4d\n",
714720
countCmds( CMDFLAG_SETTING ));
721
+ fossil_print("help-topics: %4d\n",
722
+ countCmds( CMDFLAG_TOPIC ));
715723
fossil_print("total entries: %4d\n", MX_COMMAND);
716724
}
717725
718726
/*
719727
** Compute an estimate of the edit-distance between to input strings.
@@ -892,10 +900,12 @@
892900
/* Some of the webpages require query parameters in order to work.
893901
** @ <h1>The "<a href='%R%s(zCmd)'>%s(zCmd)</a>" page:</h1> */
894902
@ <h1>The "%h(pCmd->zName)" page:</h1>
895903
}else if( rc==0 && (pCmd->eCmdFlags & CMDFLAG_SETTING)!=0 ){
896904
@ <h1>The "%h(pCmd->zName)" setting:</h1>
905
+ }else if( rc==0 && (pCmd->eCmdFlags & CMDFLAG_TOPIC)!=0 ){
906
+ @ <h1>The "%h(pCmd->zName)" help topic:</h1>
897907
}else{
898908
@ <h1>The "%h(pCmd->zName)" command:</h1>
899909
}
900910
if( rc==1 || (rc==2 && zCmd[0]=='/') ){
901911
if( zCmd && help_is_platform_command(zCmd) ){
@@ -933,11 +943,11 @@
933943
int bktHelp[FOSSIL_MX_CMDIDX][MX_HELP_DUP] = {{0}};/* Help str->commands */
934944
style_header("Help");
935945
search_screen(SRCH_HELP, 0x02);
936946
937947
@ <a name='commands'></a>
938
- @ <h1>Available commands:</h1>
948
+ @ <h1>Commands:</h1>
939949
@ <div class="columns" style="column-width: %s(zWidth);">
940950
@ <ul>
941951
/* Fill in help string buckets */
942952
for(i=0; i<MX_COMMAND; i++){
943953
if(aCommand[i].eCmdFlags & CMDFLAG_HIDDEN) continue;
@@ -946,11 +956,13 @@
946956
for(i=0; i<MX_COMMAND; i++){
947957
const char *z = aCommand[i].zName;
948958
const char *zBoldOn = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"<b>" :"";
949959
const char *zBoldOff = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"</b>":"";
950960
if( '/'==*z || strncmp(z,"test",4)==0 ) continue;
951
- if( (aCommand[i].eCmdFlags & CMDFLAG_SETTING)!=0 ) continue;
961
+ if( (aCommand[i].eCmdFlags & (CMDFLAG_SETTING|CMDFLAG_TOPIC))!=0 ){
962
+ continue;
963
+ }
952964
else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
953965
else if( (aCommand[i].eCmdFlags & CMDFLAG_ALIAS)!=0 ) continue;
954966
@ <li><a href="%R/help/%s(z)">%s(zBoldOn)%s(z)%s(zBoldOff)</a>
955967
/* Output aliases */
956968
if( occHelp[aCommand[i].iHelp] > 1 ){
@@ -978,11 +990,11 @@
978990
}
979991
980992
@ </ul></div>
981993
982994
@ <a name='webpages'></a>
983
- @ <h1>Available web UI pages:</h1>
995
+ @ <h1>Web pages:</h1>
984996
@ <div class="columns" style="column-width: %s(zWidth);">
985997
@ <ul>
986998
for(i=0; i<MX_COMMAND; i++){
987999
const char *z = aCommand[i].zName;
9881000
if( '/'!=*z ) continue;
@@ -993,33 +1005,48 @@
9931005
@ <li>%s(z+1)</li>
9941006
}
9951007
}
9961008
@ </ul></div>
9971009
998
- @ <a name='unsupported'></a>
999
- @ <h1>Unsupported commands:</h1>
1010
+ @ <a name='settings'></a>
1011
+ @ <h1>Settings:</h1>
10001012
@ <div class="columns" style="column-width: %s(zWidth);">
10011013
@ <ul>
10021014
for(i=0; i<MX_COMMAND; i++){
10031015
const char *z = aCommand[i].zName;
1004
- if( strncmp(z,"test",4)!=0 ) continue;
1016
+ if( (aCommand[i].eCmdFlags & CMDFLAG_SETTING)==0 ) continue;
10051017
else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
10061018
if( aCommand[i].zHelp[0] ){
10071019
@ <li><a href="%R/help/%s(z)">%s(z)</a></li>
10081020
}else{
10091021
@ <li>%s(z)</li>
10101022
}
10111023
}
10121024
@ </ul></div>
10131025
1014
- @ <a name='settings'></a>
1015
- @ <h1>Settings:</h1>
1026
+ @ <a name='topics'></a>
1027
+ @ <h1>Other Miscellaneous Help Topics:</h1>
1028
+ @ <div class="columns" style="column-width: %s(zWidth);">
1029
+ @ <ul>
1030
+ for(i=0; i<MX_COMMAND; i++){
1031
+ const char *z = aCommand[i].zName;
1032
+ if( (aCommand[i].eCmdFlags & CMDFLAG_TOPIC)==0 ) continue;
1033
+ if( aCommand[i].zHelp[0] ){
1034
+ @ <li><a href="%R/help/%s(z)">%s(z)</a></li>
1035
+ }else{
1036
+ @ <li>%s(z)</li>
1037
+ }
1038
+ }
1039
+ @ </ul></div>
1040
+
1041
+ @ <a name='unsupported'></a>
1042
+ @ <h1>Unsupported and Testing Commands:</h1>
10161043
@ <div class="columns" style="column-width: %s(zWidth);">
10171044
@ <ul>
10181045
for(i=0; i<MX_COMMAND; i++){
10191046
const char *z = aCommand[i].zName;
1020
- if( (aCommand[i].eCmdFlags & CMDFLAG_SETTING)==0 ) continue;
1047
+ if( strncmp(z,"test",4)!=0 ) continue;
10211048
else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
10221049
if( aCommand[i].zHelp[0] ){
10231050
@ <li><a href="%R/help/%s(z)">%s(z)</a></li>
10241051
}else{
10251052
@ <li>%s(z)</li>
@@ -1059,10 +1086,12 @@
10591086
zDesc = "2nd tier command";
10601087
}else if( e & CMDFLAG_ALIAS ){
10611088
zDesc = "alias";
10621089
}else if( e & CMDFLAG_TEST ){
10631090
zDesc = "test command";
1091
+ }else if( e & CMDFLAG_TOPIC ){
1092
+ zDesc = "help-topic";
10641093
}else if( e & CMDFLAG_WEBPAGE ){
10651094
if( e & CMDFLAG_RAWCONTENT ){
10661095
zDesc = "raw-content web page";
10671096
}else{
10681097
zDesc = "web page";
@@ -1392,46 +1421,44 @@
13921421
multi_column_list(aCmd, nCmd);
13931422
}
13941423
}
13951424
13961425
/*
1397
-** Documentation on universal command-line options.
1426
+** TOPIC: options
1427
+**
1428
+** Command-line options common to all commands:
1429
+**
1430
+** --args FILENAME Read additional arguments and options from FILENAME
1431
+** --case-sensitive BOOL Set case sensitivity for file names
1432
+** --cgitrace Active CGI tracing
1433
+** --chdir PATH Change to PATH before performing any operations
1434
+** --errorlog FILENAME Log errors to FILENAME
1435
+** -?|--help Show help on the command rather than running it
1436
+** --httptrace Trace outbound HTTP requests
1437
+** --localtime Display times using the local timezone
1438
+** --nocgi Do not act as CGI
1439
+** --no-th-hook Do not run TH1 hooks
1440
+** --quiet Reduce the amount of output
1441
+** --sqlstats Show SQL usage statistics when done
1442
+** --sqltrace Trace all SQL commands
1443
+** --sshtrace Trace SSH activity
1444
+** --ssl-identity NAME Set the SSL identity to NAME
1445
+** --systemtrace Trace calls to system()
1446
+** -U|--user USER Make the default user be USER
1447
+** --utc Display times using UTC
1448
+** --vfs NAME Cause SQLite to use the NAME VFS
1449
+**
1450
+** Additional options available on most commands that use network I/O:
1451
+**
1452
+** --accept-any-cert Disable server SSL cdert validation. Accept any SSL
1453
+** cert that the server provides. WARNING: Unsafe!
1454
+** Testing and debugging use only!
1455
+** --ipv4 Use only IPv4. Disable IPv6 support.
1456
+** --ipv6 Use only IPv6. Disable IPv4 support.
1457
+** --nosync Disable autosync for the current command.
1458
+** --proxy URL Specify the HTTP proxy to use. URL can be "off".
13981459
*/
1399
-/* @-comment: # */
1400
-static const char zOptions[] =
1401
-@ Command-line options common to all commands:
1402
-@
1403
-@ --args FILENAME Read additional arguments and options from FILENAME
1404
-@ --case-sensitive BOOL Set case sensitivity for file names
1405
-@ --cgitrace Active CGI tracing
1406
-@ --chdir PATH Change to PATH before performing any operations
1407
-@ --errorlog FILENAME Log errors to FILENAME
1408
-@ -?|--help Show help on the command rather than running it
1409
-@ --httptrace Trace outbound HTTP requests
1410
-@ --localtime Display times using the local timezone
1411
-@ --nocgi Do not act as CGI
1412
-@ --no-th-hook Do not run TH1 hooks
1413
-@ --quiet Reduce the amount of output
1414
-@ --sqlstats Show SQL usage statistics when done
1415
-@ --sqltrace Trace all SQL commands
1416
-@ --sshtrace Trace SSH activity
1417
-@ --ssl-identity NAME Set the SSL identity to NAME
1418
-@ --systemtrace Trace calls to system()
1419
-@ -U|--user USER Make the default user be USER
1420
-@ --utc Display times using UTC
1421
-@ --vfs NAME Cause SQLite to use the NAME VFS
1422
-@
1423
-@ Additional options available on most commands that use network I/O:
1424
-@
1425
-@ --accept-any-cert Disable server SSL cdert validation. Accept any SSL
1426
-@ cert that the server provides. WARNING: Unsafe!
1427
-@ Testing and debugging use only!
1428
-@ --ipv4 Use only IPv4. Disable IPv6 support.
1429
-@ --ipv6 Use only IPv6. Disable IPv4 support.
1430
-@ --nosync Disable autosync for the current command.
1431
-@ --proxy URL Specify the HTTP proxy to use. URL can be "off".
1432
-;
14331460
14341461
/*
14351462
** COMMAND: help
14361463
**
14371464
** Usage: %fossil help [OPTIONS] [TOPIC] [SUBCOMMAND]
@@ -1508,21 +1535,26 @@
15081535
return;
15091536
}
15101537
else if( find_option("setting","s",0) ){
15111538
command_list(CMDFLAG_SETTING, verboseFlag, useHtml);
15121539
return;
1540
+ }
1541
+ else if( find_option("topic","c",0) ){
1542
+ command_list(CMDFLAG_TOPIC, verboseFlag, useHtml);
1543
+ return;
15131544
}
15141545
else if( find_option("full","f",0) ){
15151546
fossil_print("fossil commands:\n\n");
15161547
command_list(CMDFLAG_1ST_TIER, verboseFlag, useHtml);
15171548
fossil_print("\nfossil auxiliary commands:\n\n");
15181549
command_list(CMDFLAG_2ND_TIER, verboseFlag, useHtml);
1519
- fossil_print("\n%s", zOptions);
15201550
fossil_print("\nfossil settings:\n\n");
15211551
command_list(CMDFLAG_SETTING, verboseFlag, useHtml);
15221552
fossil_print("\nfossil web pages:\n\n");
15231553
command_list(CMDFLAG_WEBPAGE, verboseFlag, useHtml);
1554
+ fossil_print("\nfossil miscellaneous help topics:\n\n");
1555
+ command_list(CMDFLAG_TOPIC, verboseFlag, useHtml);
15241556
fossil_print("\nfossil test commands (unsupported):\n\n");
15251557
command_list(CMDFLAG_TEST, verboseFlag, useHtml);
15261558
if ( !verboseFlag ) {
15271559
fossil_print("\n");
15281560
version_cmd();
@@ -1529,18 +1561,22 @@
15291561
}
15301562
return;
15311563
}
15321564
else if( find_option("everything","e",0) ){
15331565
display_all_help(CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER | CMDFLAG_WEBPAGE |
1534
- CMDFLAG_SETTING | CMDFLAG_TEST, useHtml, 0);
1566
+ CMDFLAG_SETTING | CMDFLAG_TEST | CMDFLAG_TOPIC,
1567
+ useHtml, 0);
15351568
return;
15361569
}
15371570
verify_all_options();
15381571
if( g.argc<3 ){
15391572
if( bOptions ){
1540
- fossil_print("%s", zOptions);
1541
- return;
1573
+ zTopic = "options";
1574
+ zSubtopic = 0;
1575
+ mask = CMDFLAG_TOPIC;
1576
+ bOptions = 0;
1577
+ goto find_and_show_help;
15421578
}
15431579
z = g.argv[0];
15441580
fossil_print(
15451581
"Usage: %s help TOPIC\n"
15461582
"Things to try:\n\n"
@@ -1558,16 +1594,17 @@
15581594
zSubtopic = g.argc>=4 ? g.argv[3] : 0;
15591595
isPage = ('/' == zTopic[0]) ? 1 : 0;
15601596
if( isPage ){
15611597
zCmdOrPage = "page";
15621598
}else if( commandsFlag ){
1563
- mask = CMDFLAG_COMMAND;
1599
+ mask = CMDFLAG_COMMAND|CMDFLAG_TOPIC;
15641600
zCmdOrPage = "command";
15651601
}else{
15661602
zCmdOrPage = "command or setting";
15671603
}
1568
- rc = dispatch_name_search(g.argv[2], mask|CMDFLAG_PREFIX, &pCmd);
1604
+find_and_show_help:
1605
+ rc = dispatch_name_search(zTopic, mask|CMDFLAG_PREFIX, &pCmd);
15691606
if( rc ){
15701607
int i, n;
15711608
const char *az[5];
15721609
if( rc==1 ){
15731610
if( help_is_platform_command(g.argv[2]) ){
@@ -1805,10 +1842,12 @@
18051842
zType = "command";
18061843
}else if( pPage->eCmdFlags & CMDFLAG_WEBPAGE ){
18071844
zType = "webpage";
18081845
}else if( pPage->eCmdFlags & CMDFLAG_SETTING ){
18091846
zType = "setting";
1847
+ }else if( pPage->eCmdFlags & CMDFLAG_TOPIC ){
1848
+ zType = "help-topic";
18101849
}
18111850
sqlite3_result_text(ctx, zType, -1, SQLITE_STATIC);
18121851
break;
18131852
}
18141853
case 2: /* flags */
18151854
--- src/dispatch.c
+++ src/dispatch.c
@@ -25,11 +25,11 @@
25 #include "dispatch.h"
26
27 #if INTERFACE
28 /*
29 ** An instance of this object defines everything we need to know about an
30 ** individual command, webpage, or setting.
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 */
@@ -39,31 +39,32 @@
39
40 /***************************************************************************
41 ** These macros must match similar macros in mkindex.c
42 ** Allowed values for CmdOrPage.eCmdFlags.
43 */
44 #define CMDFLAG_1ST_TIER 0x0001 /* Most important commands */
45 #define CMDFLAG_2ND_TIER 0x0002 /* Obscure and seldom used commands */
46 #define CMDFLAG_TEST 0x0004 /* Commands for testing only */
47 #define CMDFLAG_WEBPAGE 0x0008 /* Web pages */
48 #define CMDFLAG_COMMAND 0x0010 /* A command */
49 #define CMDFLAG_SETTING 0x0020 /* A setting */
50 #define CMDFLAG_VERSIONABLE 0x0040 /* A versionable setting */
51 #define CMDFLAG_BLOCKTEXT 0x0080 /* Multi-line text setting */
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 #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 */
65
66 #endif /* INTERFACE */
67
68 /*
69 ** The page_index.h file contains the definition for aCommand[] - an array
@@ -578,10 +579,11 @@
578 if( mask & CMDFLAG_2ND_TIER ) fossil_print(" * Auxiliary commands\n");
579 if( mask & CMDFLAG_ALIAS ) fossil_print(" * Aliases\n");
580 if( mask & CMDFLAG_TEST ) fossil_print(" * Test commands\n");
581 if( mask & CMDFLAG_WEBPAGE ) fossil_print(" * Web pages\n");
582 if( mask & CMDFLAG_SETTING ) fossil_print(" * Settings\n");
 
583 if( useHtml ){
584 fossil_print("-->\n");
585 fossil_print("<!-- start_all_help -->\n");
586 }else{
587 fossil_print("---\n");
@@ -644,10 +646,11 @@
644 ** Defaults to just the CLI commands. Specify --www to see only the
645 ** web pages, or --everything to see both commands and pages.
646 **
647 ** Options:
648 ** -a|--aliases Show aliases
 
649 ** -e|--everything Show all commands and pages. Omit aliases to
650 ** avoid duplicates.
651 ** -h|--html Transform output to HTML
652 ** -o|--options Show global options
653 ** -r|--raw No output formatting
@@ -663,20 +666,23 @@
663 if( find_option("www","w",0) ){
664 mask = CMDFLAG_WEBPAGE;
665 }
666 if( find_option("everything","e",0) ){
667 mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER | CMDFLAG_WEBPAGE |
668 CMDFLAG_ALIAS | CMDFLAG_SETTING | CMDFLAG_TEST;
669 }
670 if( find_option("settings","s",0) ){
671 mask = CMDFLAG_SETTING;
672 }
673 if( find_option("aliases","a",0) ){
674 mask = CMDFLAG_ALIAS;
675 }
676 if( find_option("test","t",0) ){
677 mask |= CMDFLAG_TEST;
 
 
 
678 }
679 display_all_help(mask, useHtml, rawOut);
680 }
681
682 /*
@@ -710,10 +716,12 @@
710 countCmds( CMDFLAG_TEST ));
711 fossil_print("web-pages: %4d\n",
712 countCmds( CMDFLAG_WEBPAGE ));
713 fossil_print("settings: %4d\n",
714 countCmds( CMDFLAG_SETTING ));
 
 
715 fossil_print("total entries: %4d\n", MX_COMMAND);
716 }
717
718 /*
719 ** Compute an estimate of the edit-distance between to input strings.
@@ -892,10 +900,12 @@
892 /* Some of the webpages require query parameters in order to work.
893 ** @ <h1>The "<a href='%R%s(zCmd)'>%s(zCmd)</a>" page:</h1> */
894 @ <h1>The "%h(pCmd->zName)" page:</h1>
895 }else if( rc==0 && (pCmd->eCmdFlags & CMDFLAG_SETTING)!=0 ){
896 @ <h1>The "%h(pCmd->zName)" setting:</h1>
 
 
897 }else{
898 @ <h1>The "%h(pCmd->zName)" command:</h1>
899 }
900 if( rc==1 || (rc==2 && zCmd[0]=='/') ){
901 if( zCmd && help_is_platform_command(zCmd) ){
@@ -933,11 +943,11 @@
933 int bktHelp[FOSSIL_MX_CMDIDX][MX_HELP_DUP] = {{0}};/* Help str->commands */
934 style_header("Help");
935 search_screen(SRCH_HELP, 0x02);
936
937 @ <a name='commands'></a>
938 @ <h1>Available commands:</h1>
939 @ <div class="columns" style="column-width: %s(zWidth);">
940 @ <ul>
941 /* Fill in help string buckets */
942 for(i=0; i<MX_COMMAND; i++){
943 if(aCommand[i].eCmdFlags & CMDFLAG_HIDDEN) continue;
@@ -946,11 +956,13 @@
946 for(i=0; i<MX_COMMAND; i++){
947 const char *z = aCommand[i].zName;
948 const char *zBoldOn = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"<b>" :"";
949 const char *zBoldOff = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"</b>":"";
950 if( '/'==*z || strncmp(z,"test",4)==0 ) continue;
951 if( (aCommand[i].eCmdFlags & CMDFLAG_SETTING)!=0 ) continue;
 
 
952 else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
953 else if( (aCommand[i].eCmdFlags & CMDFLAG_ALIAS)!=0 ) continue;
954 @ <li><a href="%R/help/%s(z)">%s(zBoldOn)%s(z)%s(zBoldOff)</a>
955 /* Output aliases */
956 if( occHelp[aCommand[i].iHelp] > 1 ){
@@ -978,11 +990,11 @@
978 }
979
980 @ </ul></div>
981
982 @ <a name='webpages'></a>
983 @ <h1>Available web UI pages:</h1>
984 @ <div class="columns" style="column-width: %s(zWidth);">
985 @ <ul>
986 for(i=0; i<MX_COMMAND; i++){
987 const char *z = aCommand[i].zName;
988 if( '/'!=*z ) continue;
@@ -993,33 +1005,48 @@
993 @ <li>%s(z+1)</li>
994 }
995 }
996 @ </ul></div>
997
998 @ <a name='unsupported'></a>
999 @ <h1>Unsupported commands:</h1>
1000 @ <div class="columns" style="column-width: %s(zWidth);">
1001 @ <ul>
1002 for(i=0; i<MX_COMMAND; i++){
1003 const char *z = aCommand[i].zName;
1004 if( strncmp(z,"test",4)!=0 ) continue;
1005 else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
1006 if( aCommand[i].zHelp[0] ){
1007 @ <li><a href="%R/help/%s(z)">%s(z)</a></li>
1008 }else{
1009 @ <li>%s(z)</li>
1010 }
1011 }
1012 @ </ul></div>
1013
1014 @ <a name='settings'></a>
1015 @ <h1>Settings:</h1>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1016 @ <div class="columns" style="column-width: %s(zWidth);">
1017 @ <ul>
1018 for(i=0; i<MX_COMMAND; i++){
1019 const char *z = aCommand[i].zName;
1020 if( (aCommand[i].eCmdFlags & CMDFLAG_SETTING)==0 ) continue;
1021 else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
1022 if( aCommand[i].zHelp[0] ){
1023 @ <li><a href="%R/help/%s(z)">%s(z)</a></li>
1024 }else{
1025 @ <li>%s(z)</li>
@@ -1059,10 +1086,12 @@
1059 zDesc = "2nd tier command";
1060 }else if( e & CMDFLAG_ALIAS ){
1061 zDesc = "alias";
1062 }else if( e & CMDFLAG_TEST ){
1063 zDesc = "test command";
 
 
1064 }else if( e & CMDFLAG_WEBPAGE ){
1065 if( e & CMDFLAG_RAWCONTENT ){
1066 zDesc = "raw-content web page";
1067 }else{
1068 zDesc = "web page";
@@ -1392,46 +1421,44 @@
1392 multi_column_list(aCmd, nCmd);
1393 }
1394 }
1395
1396 /*
1397 ** Documentation on universal command-line options.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1398 */
1399 /* @-comment: # */
1400 static const char zOptions[] =
1401 @ Command-line options common to all commands:
1402 @
1403 @ --args FILENAME Read additional arguments and options from FILENAME
1404 @ --case-sensitive BOOL Set case sensitivity for file names
1405 @ --cgitrace Active CGI tracing
1406 @ --chdir PATH Change to PATH before performing any operations
1407 @ --errorlog FILENAME Log errors to FILENAME
1408 @ -?|--help Show help on the command rather than running it
1409 @ --httptrace Trace outbound HTTP requests
1410 @ --localtime Display times using the local timezone
1411 @ --nocgi Do not act as CGI
1412 @ --no-th-hook Do not run TH1 hooks
1413 @ --quiet Reduce the amount of output
1414 @ --sqlstats Show SQL usage statistics when done
1415 @ --sqltrace Trace all SQL commands
1416 @ --sshtrace Trace SSH activity
1417 @ --ssl-identity NAME Set the SSL identity to NAME
1418 @ --systemtrace Trace calls to system()
1419 @ -U|--user USER Make the default user be USER
1420 @ --utc Display times using UTC
1421 @ --vfs NAME Cause SQLite to use the NAME VFS
1422 @
1423 @ Additional options available on most commands that use network I/O:
1424 @
1425 @ --accept-any-cert Disable server SSL cdert validation. Accept any SSL
1426 @ cert that the server provides. WARNING: Unsafe!
1427 @ Testing and debugging use only!
1428 @ --ipv4 Use only IPv4. Disable IPv6 support.
1429 @ --ipv6 Use only IPv6. Disable IPv4 support.
1430 @ --nosync Disable autosync for the current command.
1431 @ --proxy URL Specify the HTTP proxy to use. URL can be "off".
1432 ;
1433
1434 /*
1435 ** COMMAND: help
1436 **
1437 ** Usage: %fossil help [OPTIONS] [TOPIC] [SUBCOMMAND]
@@ -1508,21 +1535,26 @@
1508 return;
1509 }
1510 else if( find_option("setting","s",0) ){
1511 command_list(CMDFLAG_SETTING, verboseFlag, useHtml);
1512 return;
 
 
 
 
1513 }
1514 else if( find_option("full","f",0) ){
1515 fossil_print("fossil commands:\n\n");
1516 command_list(CMDFLAG_1ST_TIER, verboseFlag, useHtml);
1517 fossil_print("\nfossil auxiliary commands:\n\n");
1518 command_list(CMDFLAG_2ND_TIER, verboseFlag, useHtml);
1519 fossil_print("\n%s", zOptions);
1520 fossil_print("\nfossil settings:\n\n");
1521 command_list(CMDFLAG_SETTING, verboseFlag, useHtml);
1522 fossil_print("\nfossil web pages:\n\n");
1523 command_list(CMDFLAG_WEBPAGE, verboseFlag, useHtml);
 
 
1524 fossil_print("\nfossil test commands (unsupported):\n\n");
1525 command_list(CMDFLAG_TEST, verboseFlag, useHtml);
1526 if ( !verboseFlag ) {
1527 fossil_print("\n");
1528 version_cmd();
@@ -1529,18 +1561,22 @@
1529 }
1530 return;
1531 }
1532 else if( find_option("everything","e",0) ){
1533 display_all_help(CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER | CMDFLAG_WEBPAGE |
1534 CMDFLAG_SETTING | CMDFLAG_TEST, useHtml, 0);
 
1535 return;
1536 }
1537 verify_all_options();
1538 if( g.argc<3 ){
1539 if( bOptions ){
1540 fossil_print("%s", zOptions);
1541 return;
 
 
 
1542 }
1543 z = g.argv[0];
1544 fossil_print(
1545 "Usage: %s help TOPIC\n"
1546 "Things to try:\n\n"
@@ -1558,16 +1594,17 @@
1558 zSubtopic = g.argc>=4 ? g.argv[3] : 0;
1559 isPage = ('/' == zTopic[0]) ? 1 : 0;
1560 if( isPage ){
1561 zCmdOrPage = "page";
1562 }else if( commandsFlag ){
1563 mask = CMDFLAG_COMMAND;
1564 zCmdOrPage = "command";
1565 }else{
1566 zCmdOrPage = "command or setting";
1567 }
1568 rc = dispatch_name_search(g.argv[2], mask|CMDFLAG_PREFIX, &pCmd);
 
1569 if( rc ){
1570 int i, n;
1571 const char *az[5];
1572 if( rc==1 ){
1573 if( help_is_platform_command(g.argv[2]) ){
@@ -1805,10 +1842,12 @@
1805 zType = "command";
1806 }else if( pPage->eCmdFlags & CMDFLAG_WEBPAGE ){
1807 zType = "webpage";
1808 }else if( pPage->eCmdFlags & CMDFLAG_SETTING ){
1809 zType = "setting";
 
 
1810 }
1811 sqlite3_result_text(ctx, zType, -1, SQLITE_STATIC);
1812 break;
1813 }
1814 case 2: /* flags */
1815
--- src/dispatch.c
+++ src/dispatch.c
@@ -25,11 +25,11 @@
25 #include "dispatch.h"
26
27 #if INTERFACE
28 /*
29 ** An instance of this object defines everything we need to know about an
30 ** individual command, webpage, setting, or help topic.
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 */
@@ -39,31 +39,32 @@
39
40 /***************************************************************************
41 ** These macros must match similar macros in mkindex.c
42 ** Allowed values for CmdOrPage.eCmdFlags.
43 */
44 #define CMDFLAG_1ST_TIER 0x000001 /* Most important commands */
45 #define CMDFLAG_2ND_TIER 0x000002 /* Obscure and seldom used commands */
46 #define CMDFLAG_TEST 0x000004 /* Commands for testing only */
47 #define CMDFLAG_WEBPAGE 0x000008 /* Web pages */
48 #define CMDFLAG_COMMAND 0x000010 /* A command */
49 #define CMDFLAG_SETTING 0x000020 /* A setting */
50 #define CMDFLAG_VERSIONABLE 0x000040 /* A versionable setting */
51 #define CMDFLAG_BLOCKTEXT 0x000080 /* Multi-line text setting */
52 #define CMDFLAG_BOOLEAN 0x000100 /* A boolean setting */
53 #define CMDFLAG_RAWCONTENT 0x000200 /* Do not interpret POST content */
54 /* NOTE: 0x000400 = CMDFLAG_SENSITIVE in mkindex.c! */
55 #define CMDFLAG_HIDDEN 0x000800 /* Elide from most listings */
56 #define CMDFLAG_LDAVG_EXEMPT 0x001000 /* Exempt from load_control() */
57 #define CMDFLAG_ALIAS 0x002000 /* Command aliases */
58 #define CMDFLAG_KEEPEMPTY 0x004000 /* Do not unset empty settings */
59 #define CMDFLAG_ABBREVSUBCMD 0x008000 /* Help text abbreviates subcommands */
60 #define CMDFLAG_TOPIC 0x010000 /* A help topic */
61 /**************************************************************************/
62
63 /* Values for the 2nd parameter to dispatch_name_search() */
64 #define CMDFLAG_ANY 0x010038 /* Match anything */
65 #define CMDFLAG_PREFIX 0x000200 /* Prefix match is OK */
66
67 #endif /* INTERFACE */
68
69 /*
70 ** The page_index.h file contains the definition for aCommand[] - an array
@@ -578,10 +579,11 @@
579 if( mask & CMDFLAG_2ND_TIER ) fossil_print(" * Auxiliary commands\n");
580 if( mask & CMDFLAG_ALIAS ) fossil_print(" * Aliases\n");
581 if( mask & CMDFLAG_TEST ) fossil_print(" * Test commands\n");
582 if( mask & CMDFLAG_WEBPAGE ) fossil_print(" * Web pages\n");
583 if( mask & CMDFLAG_SETTING ) fossil_print(" * Settings\n");
584 if( mask & CMDFLAG_TOPIC ) fossil_print(" * Help Topic\n");
585 if( useHtml ){
586 fossil_print("-->\n");
587 fossil_print("<!-- start_all_help -->\n");
588 }else{
589 fossil_print("---\n");
@@ -644,10 +646,11 @@
646 ** Defaults to just the CLI commands. Specify --www to see only the
647 ** web pages, or --everything to see both commands and pages.
648 **
649 ** Options:
650 ** -a|--aliases Show aliases
651 ** -c|--topics Show help topics
652 ** -e|--everything Show all commands and pages. Omit aliases to
653 ** avoid duplicates.
654 ** -h|--html Transform output to HTML
655 ** -o|--options Show global options
656 ** -r|--raw No output formatting
@@ -663,20 +666,23 @@
666 if( find_option("www","w",0) ){
667 mask = CMDFLAG_WEBPAGE;
668 }
669 if( find_option("everything","e",0) ){
670 mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER | CMDFLAG_WEBPAGE |
671 CMDFLAG_ALIAS | CMDFLAG_SETTING | CMDFLAG_TEST | CMDFLAG_TOPIC;
672 }
673 if( find_option("settings","s",0) ){
674 mask = CMDFLAG_SETTING;
675 }
676 if( find_option("aliases","a",0) ){
677 mask = CMDFLAG_ALIAS;
678 }
679 if( find_option("test","t",0) ){
680 mask |= CMDFLAG_TEST;
681 }
682 if( find_option("topics","c",0) ){
683 mask |= CMDFLAG_TOPIC;
684 }
685 display_all_help(mask, useHtml, rawOut);
686 }
687
688 /*
@@ -710,10 +716,12 @@
716 countCmds( CMDFLAG_TEST ));
717 fossil_print("web-pages: %4d\n",
718 countCmds( CMDFLAG_WEBPAGE ));
719 fossil_print("settings: %4d\n",
720 countCmds( CMDFLAG_SETTING ));
721 fossil_print("help-topics: %4d\n",
722 countCmds( CMDFLAG_TOPIC ));
723 fossil_print("total entries: %4d\n", MX_COMMAND);
724 }
725
726 /*
727 ** Compute an estimate of the edit-distance between to input strings.
@@ -892,10 +900,12 @@
900 /* Some of the webpages require query parameters in order to work.
901 ** @ <h1>The "<a href='%R%s(zCmd)'>%s(zCmd)</a>" page:</h1> */
902 @ <h1>The "%h(pCmd->zName)" page:</h1>
903 }else if( rc==0 && (pCmd->eCmdFlags & CMDFLAG_SETTING)!=0 ){
904 @ <h1>The "%h(pCmd->zName)" setting:</h1>
905 }else if( rc==0 && (pCmd->eCmdFlags & CMDFLAG_TOPIC)!=0 ){
906 @ <h1>The "%h(pCmd->zName)" help topic:</h1>
907 }else{
908 @ <h1>The "%h(pCmd->zName)" command:</h1>
909 }
910 if( rc==1 || (rc==2 && zCmd[0]=='/') ){
911 if( zCmd && help_is_platform_command(zCmd) ){
@@ -933,11 +943,11 @@
943 int bktHelp[FOSSIL_MX_CMDIDX][MX_HELP_DUP] = {{0}};/* Help str->commands */
944 style_header("Help");
945 search_screen(SRCH_HELP, 0x02);
946
947 @ <a name='commands'></a>
948 @ <h1>Commands:</h1>
949 @ <div class="columns" style="column-width: %s(zWidth);">
950 @ <ul>
951 /* Fill in help string buckets */
952 for(i=0; i<MX_COMMAND; i++){
953 if(aCommand[i].eCmdFlags & CMDFLAG_HIDDEN) continue;
@@ -946,11 +956,13 @@
956 for(i=0; i<MX_COMMAND; i++){
957 const char *z = aCommand[i].zName;
958 const char *zBoldOn = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"<b>" :"";
959 const char *zBoldOff = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"</b>":"";
960 if( '/'==*z || strncmp(z,"test",4)==0 ) continue;
961 if( (aCommand[i].eCmdFlags & (CMDFLAG_SETTING|CMDFLAG_TOPIC))!=0 ){
962 continue;
963 }
964 else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
965 else if( (aCommand[i].eCmdFlags & CMDFLAG_ALIAS)!=0 ) continue;
966 @ <li><a href="%R/help/%s(z)">%s(zBoldOn)%s(z)%s(zBoldOff)</a>
967 /* Output aliases */
968 if( occHelp[aCommand[i].iHelp] > 1 ){
@@ -978,11 +990,11 @@
990 }
991
992 @ </ul></div>
993
994 @ <a name='webpages'></a>
995 @ <h1>Web pages:</h1>
996 @ <div class="columns" style="column-width: %s(zWidth);">
997 @ <ul>
998 for(i=0; i<MX_COMMAND; i++){
999 const char *z = aCommand[i].zName;
1000 if( '/'!=*z ) continue;
@@ -993,33 +1005,48 @@
1005 @ <li>%s(z+1)</li>
1006 }
1007 }
1008 @ </ul></div>
1009
1010 @ <a name='settings'></a>
1011 @ <h1>Settings:</h1>
1012 @ <div class="columns" style="column-width: %s(zWidth);">
1013 @ <ul>
1014 for(i=0; i<MX_COMMAND; i++){
1015 const char *z = aCommand[i].zName;
1016 if( (aCommand[i].eCmdFlags & CMDFLAG_SETTING)==0 ) continue;
1017 else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
1018 if( aCommand[i].zHelp[0] ){
1019 @ <li><a href="%R/help/%s(z)">%s(z)</a></li>
1020 }else{
1021 @ <li>%s(z)</li>
1022 }
1023 }
1024 @ </ul></div>
1025
1026 @ <a name='topics'></a>
1027 @ <h1>Other Miscellaneous Help Topics:</h1>
1028 @ <div class="columns" style="column-width: %s(zWidth);">
1029 @ <ul>
1030 for(i=0; i<MX_COMMAND; i++){
1031 const char *z = aCommand[i].zName;
1032 if( (aCommand[i].eCmdFlags & CMDFLAG_TOPIC)==0 ) continue;
1033 if( aCommand[i].zHelp[0] ){
1034 @ <li><a href="%R/help/%s(z)">%s(z)</a></li>
1035 }else{
1036 @ <li>%s(z)</li>
1037 }
1038 }
1039 @ </ul></div>
1040
1041 @ <a name='unsupported'></a>
1042 @ <h1>Unsupported and Testing Commands:</h1>
1043 @ <div class="columns" style="column-width: %s(zWidth);">
1044 @ <ul>
1045 for(i=0; i<MX_COMMAND; i++){
1046 const char *z = aCommand[i].zName;
1047 if( strncmp(z,"test",4)!=0 ) continue;
1048 else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
1049 if( aCommand[i].zHelp[0] ){
1050 @ <li><a href="%R/help/%s(z)">%s(z)</a></li>
1051 }else{
1052 @ <li>%s(z)</li>
@@ -1059,10 +1086,12 @@
1086 zDesc = "2nd tier command";
1087 }else if( e & CMDFLAG_ALIAS ){
1088 zDesc = "alias";
1089 }else if( e & CMDFLAG_TEST ){
1090 zDesc = "test command";
1091 }else if( e & CMDFLAG_TOPIC ){
1092 zDesc = "help-topic";
1093 }else if( e & CMDFLAG_WEBPAGE ){
1094 if( e & CMDFLAG_RAWCONTENT ){
1095 zDesc = "raw-content web page";
1096 }else{
1097 zDesc = "web page";
@@ -1392,46 +1421,44 @@
1421 multi_column_list(aCmd, nCmd);
1422 }
1423 }
1424
1425 /*
1426 ** TOPIC: options
1427 **
1428 ** Command-line options common to all commands:
1429 **
1430 ** --args FILENAME Read additional arguments and options from FILENAME
1431 ** --case-sensitive BOOL Set case sensitivity for file names
1432 ** --cgitrace Active CGI tracing
1433 ** --chdir PATH Change to PATH before performing any operations
1434 ** --errorlog FILENAME Log errors to FILENAME
1435 ** -?|--help Show help on the command rather than running it
1436 ** --httptrace Trace outbound HTTP requests
1437 ** --localtime Display times using the local timezone
1438 ** --nocgi Do not act as CGI
1439 ** --no-th-hook Do not run TH1 hooks
1440 ** --quiet Reduce the amount of output
1441 ** --sqlstats Show SQL usage statistics when done
1442 ** --sqltrace Trace all SQL commands
1443 ** --sshtrace Trace SSH activity
1444 ** --ssl-identity NAME Set the SSL identity to NAME
1445 ** --systemtrace Trace calls to system()
1446 ** -U|--user USER Make the default user be USER
1447 ** --utc Display times using UTC
1448 ** --vfs NAME Cause SQLite to use the NAME VFS
1449 **
1450 ** Additional options available on most commands that use network I/O:
1451 **
1452 ** --accept-any-cert Disable server SSL cdert validation. Accept any SSL
1453 ** cert that the server provides. WARNING: Unsafe!
1454 ** Testing and debugging use only!
1455 ** --ipv4 Use only IPv4. Disable IPv6 support.
1456 ** --ipv6 Use only IPv6. Disable IPv4 support.
1457 ** --nosync Disable autosync for the current command.
1458 ** --proxy URL Specify the HTTP proxy to use. URL can be "off".
1459 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1460
1461 /*
1462 ** COMMAND: help
1463 **
1464 ** Usage: %fossil help [OPTIONS] [TOPIC] [SUBCOMMAND]
@@ -1508,21 +1535,26 @@
1535 return;
1536 }
1537 else if( find_option("setting","s",0) ){
1538 command_list(CMDFLAG_SETTING, verboseFlag, useHtml);
1539 return;
1540 }
1541 else if( find_option("topic","c",0) ){
1542 command_list(CMDFLAG_TOPIC, verboseFlag, useHtml);
1543 return;
1544 }
1545 else if( find_option("full","f",0) ){
1546 fossil_print("fossil commands:\n\n");
1547 command_list(CMDFLAG_1ST_TIER, verboseFlag, useHtml);
1548 fossil_print("\nfossil auxiliary commands:\n\n");
1549 command_list(CMDFLAG_2ND_TIER, verboseFlag, useHtml);
 
1550 fossil_print("\nfossil settings:\n\n");
1551 command_list(CMDFLAG_SETTING, verboseFlag, useHtml);
1552 fossil_print("\nfossil web pages:\n\n");
1553 command_list(CMDFLAG_WEBPAGE, verboseFlag, useHtml);
1554 fossil_print("\nfossil miscellaneous help topics:\n\n");
1555 command_list(CMDFLAG_TOPIC, verboseFlag, useHtml);
1556 fossil_print("\nfossil test commands (unsupported):\n\n");
1557 command_list(CMDFLAG_TEST, verboseFlag, useHtml);
1558 if ( !verboseFlag ) {
1559 fossil_print("\n");
1560 version_cmd();
@@ -1529,18 +1561,22 @@
1561 }
1562 return;
1563 }
1564 else if( find_option("everything","e",0) ){
1565 display_all_help(CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER | CMDFLAG_WEBPAGE |
1566 CMDFLAG_SETTING | CMDFLAG_TEST | CMDFLAG_TOPIC,
1567 useHtml, 0);
1568 return;
1569 }
1570 verify_all_options();
1571 if( g.argc<3 ){
1572 if( bOptions ){
1573 zTopic = "options";
1574 zSubtopic = 0;
1575 mask = CMDFLAG_TOPIC;
1576 bOptions = 0;
1577 goto find_and_show_help;
1578 }
1579 z = g.argv[0];
1580 fossil_print(
1581 "Usage: %s help TOPIC\n"
1582 "Things to try:\n\n"
@@ -1558,16 +1594,17 @@
1594 zSubtopic = g.argc>=4 ? g.argv[3] : 0;
1595 isPage = ('/' == zTopic[0]) ? 1 : 0;
1596 if( isPage ){
1597 zCmdOrPage = "page";
1598 }else if( commandsFlag ){
1599 mask = CMDFLAG_COMMAND|CMDFLAG_TOPIC;
1600 zCmdOrPage = "command";
1601 }else{
1602 zCmdOrPage = "command or setting";
1603 }
1604 find_and_show_help:
1605 rc = dispatch_name_search(zTopic, mask|CMDFLAG_PREFIX, &pCmd);
1606 if( rc ){
1607 int i, n;
1608 const char *az[5];
1609 if( rc==1 ){
1610 if( help_is_platform_command(g.argv[2]) ){
@@ -1805,10 +1842,12 @@
1842 zType = "command";
1843 }else if( pPage->eCmdFlags & CMDFLAG_WEBPAGE ){
1844 zType = "webpage";
1845 }else if( pPage->eCmdFlags & CMDFLAG_SETTING ){
1846 zType = "setting";
1847 }else if( pPage->eCmdFlags & CMDFLAG_TOPIC ){
1848 zType = "help-topic";
1849 }
1850 sqlite3_result_text(ctx, zType, -1, SQLITE_STATIC);
1851 break;
1852 }
1853 case 2: /* flags */
1854
+61 -23
--- tools/mkindex.c
+++ tools/mkindex.c
@@ -17,15 +17,38 @@
1717
**
1818
** This utility program scans Fossil source text looking for specially
1919
** formatted comments and generates C source code for constant tables
2020
** that define the behavior of commands, webpages, and settings.
2121
**
22
+** USAGE:
23
+**
24
+** mkindex *.c >page_index.h
25
+**
26
+** Run this command with arguments that are all input source files to
27
+** scan. Generated C code appears on standard output. The generated
28
+** C code includes structures that:
29
+**
30
+** * Map command names to the C-language functions that implement
31
+** those command.
32
+**
33
+** * Map webpage names to the C-language functions that implement
34
+** those web pages.
35
+**
36
+** * Map settings into attributes, such as they default value for
37
+** each setting, and the kind of value (boolean, multi-line, etc).
38
+**
39
+** * Provide help text for commands, webpages, settings, and other
40
+** miscellanous help topics.
41
+**
42
+** COMMENT TEXT THAT THIS PROGRAM LOOKS FOR:
43
+**
2244
** The source code is scanned for comment lines of the form:
2345
**
2446
** WEBPAGE: /abc/xyz
2547
** COMMAND: cmdname
2648
** SETTING: access-log
49
+** TOPIC: help-topic
2750
**
2851
** The WEBPAGE and COMMAND comments should be followed by a function that
2952
** implements the webpage or command. The form of this function is:
3053
**
3154
** void function_name(void){
@@ -75,10 +98,22 @@
7598
** SETTING: pgp-command
7699
** DEFAULT: gpg --clearsign -o
77100
**
78101
** If no default is supplied, the default is assumed to be an empty string
79102
** or "off" in the case of a boolean.
103
+**
104
+** A TOPIC: is followed by help text for the named topic.
105
+**
106
+** OUTPUTS:
107
+**
108
+** The output is C-language text to define and initialize a constant
109
+** array of CmdOrPage objects named "aCommand[]". That array is a global
110
+** variable. The dispatch.c source file defines the CmdOrPage object and
111
+** deals with the aCommand[] global variable.
112
+**
113
+** The output also contains a constant array of Setting objects named
114
+** aSetting[]. The Setting object is defined in db.c.
80115
*/
81116
#include <stdio.h>
82117
#include <stdlib.h>
83118
#include <assert.h>
84119
#include <string.h>
@@ -85,26 +120,27 @@
85120
86121
/***************************************************************************
87122
** These macros must match similar macros in dispatch.c.
88123
**
89124
** Allowed values for CmdOrPage.eCmdFlags. */
90
-#define CMDFLAG_1ST_TIER 0x00001 /* Most important commands */
91
-#define CMDFLAG_2ND_TIER 0x00002 /* Obscure and seldom used commands */
92
-#define CMDFLAG_TEST 0x00004 /* Commands for testing only */
93
-#define CMDFLAG_WEBPAGE 0x00008 /* Web pages */
94
-#define CMDFLAG_COMMAND 0x00010 /* A command */
95
-#define CMDFLAG_SETTING 0x00020 /* A setting */
96
-#define CMDFLAG_VERSIONABLE 0x00040 /* A versionable setting */
97
-#define CMDFLAG_BLOCKTEXT 0x00080 /* Multi-line text setting */
98
-#define CMDFLAG_BOOLEAN 0x00100 /* A boolean setting */
99
-#define CMDFLAG_RAWCONTENT 0x00200 /* Do not interpret webpage content */
100
-#define CMDFLAG_SENSITIVE 0x00400 /* Security-sensitive setting */
101
-#define CMDFLAG_HIDDEN 0x00800 /* Elide from most listings */
102
-#define CMDFLAG_LDAVG_EXEMPT 0x01000 /* Exempt from load_control() */
103
-#define CMDFLAG_ALIAS 0x02000 /* Command aliases */
104
-#define CMDFLAG_KEEPEMPTY 0x04000 /* Do not unset empty settings */
105
-#define CMDFLAG_ABBREVSUBCMD 0x08000 /* Abbreviated subcmd in help text */
125
+#define CMDFLAG_1ST_TIER 0x000001 /* Most important commands */
126
+#define CMDFLAG_2ND_TIER 0x000002 /* Obscure and seldom used commands */
127
+#define CMDFLAG_TEST 0x000004 /* Commands for testing only */
128
+#define CMDFLAG_WEBPAGE 0x000008 /* Web pages */
129
+#define CMDFLAG_COMMAND 0x000010 /* A command */
130
+#define CMDFLAG_SETTING 0x000020 /* A setting */
131
+#define CMDFLAG_VERSIONABLE 0x000040 /* A versionable setting */
132
+#define CMDFLAG_BLOCKTEXT 0x000080 /* Multi-line text setting */
133
+#define CMDFLAG_BOOLEAN 0x000100 /* A boolean setting */
134
+#define CMDFLAG_RAWCONTENT 0x000200 /* Do not interpret webpage content */
135
+#define CMDFLAG_SENSITIVE 0x000400 /* Security-sensitive setting */
136
+#define CMDFLAG_HIDDEN 0x000800 /* Elide from most listings */
137
+#define CMDFLAG_LDAVG_EXEMPT 0x001000 /* Exempt from load_control() */
138
+#define CMDFLAG_ALIAS 0x002000 /* Command aliases */
139
+#define CMDFLAG_KEEPEMPTY 0x004000 /* Do not unset empty settings */
140
+#define CMDFLAG_ABBREVSUBCMD 0x008000 /* Abbreviated subcmd in help text */
141
+#define CMDFLAG_TOPIC 0x010000 /* A help topic */
106142
/**************************************************************************/
107143
108144
/*
109145
** Each entry looks like this:
110146
*/
@@ -343,20 +379,21 @@
343379
** Scan a line for a function that implements a web page or command.
344380
*/
345381
void scan_for_func(char *zLine){
346382
int i,j,k;
347383
char *z;
348
- int isSetting;
384
+ int hasFunc;
349385
if( nUsed<=nFixed ) return;
350386
if( strncmp(zLine, "**", 2)==0
351387
&& fossil_isspace(zLine[2])
352388
&& strlen(zLine)<sizeof(zHelp)-nHelp-1
353389
&& nUsed>nFixed
354390
&& strncmp(zLine,"** COMMAND:",11)!=0
355391
&& strncmp(zLine,"** WEBPAGE:",11)!=0
356392
&& strncmp(zLine,"** SETTING:",11)!=0
357393
&& strncmp(zLine,"** DEFAULT:",11)!=0
394
+ && strncmp(zLine,"** TOPIC:",9)!=0
358395
){
359396
if( zLine[2]=='\n' ){
360397
zHelp[nHelp++] = '\n';
361398
}else{
362399
if( strncmp(&zLine[3], "Usage: ", 6)==0 ) nHelp = 0;
@@ -365,12 +402,12 @@
365402
}
366403
return;
367404
}
368405
for(i=0; fossil_isspace(zLine[i]); i++){}
369406
if( zLine[i]==0 ) return;
370
- isSetting = (aEntry[nFixed].eType & CMDFLAG_SETTING)!=0;
371
- if( !isSetting ){
407
+ hasFunc = (aEntry[nFixed].eType & (CMDFLAG_SETTING|CMDFLAG_TOPIC))==0;
408
+ if( hasFunc ){
372409
if( strncmp(&zLine[i],"void",4)!=0 ){
373410
if( zLine[i]!='*' ) goto page_skip;
374411
return;
375412
}
376413
i += 4;
@@ -390,16 +427,16 @@
390427
}else{
391428
z = "";
392429
}
393430
for(k=nFixed; k<nUsed; k++){
394431
aEntry[k].zIf = zIf[0] ? string_dup(zIf, -1) : 0;
395
- aEntry[k].zFunc = isSetting ? "0" : string_dup(&zLine[i], j);
432
+ aEntry[k].zFunc = hasFunc ? string_dup(&zLine[i], j) : "0";
396433
aEntry[k].zHelp = z;
397434
z = 0;
398435
aEntry[k].iHelp = nFixed;
399436
}
400
- if( !isSetting ){
437
+ if( hasFunc ){
401438
i+=j;
402439
while( fossil_isspace(zLine[i]) ){ i++; }
403440
if( zLine[i]!='(' ) goto page_skip;
404441
}
405442
nFixed = nUsed;
@@ -442,11 +479,11 @@
442479
"*/\n"
443480
);
444481
445482
/* Output declarations for all the action functions */
446483
for(i=0; i<nFixed; i++){
447
- if( aEntry[i].eType & CMDFLAG_SETTING ) continue;
484
+ if( aEntry[i].eType & (CMDFLAG_SETTING|CMDFLAG_TOPIC) ) continue;
448485
if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf);
449486
printf("extern void %s(void);\n", aEntry[i].zFunc);
450487
if( aEntry[i].zIf ) printf("#endif\n");
451488
}
452489
@@ -479,11 +516,11 @@
479516
if( aEntry[i].zIf ){
480517
printf("%s", aEntry[i].zIf);
481518
}else if( (aEntry[i].eType & CMDFLAG_WEBPAGE)!=0 ){
482519
nWeb++;
483520
}
484
- printf(" { \"%.*s\",%*s%s,%*szHelp%03d, %3d, 0x%03x },\n",
521
+ printf(" { \"%.*s\",%*s%s,%*szHelp%03d, %3d, 0x%05x },\n",
485522
n, z,
486523
25-n, "",
487524
aEntry[i].zFunc,
488525
(int)(29-strlen(aEntry[i].zFunc)), "",
489526
aEntry[i].iHelp,
@@ -550,10 +587,11 @@
550587
scan_for_label("WEBPAGE:",zLine,CMDFLAG_WEBPAGE);
551588
scan_for_label("COMMAND:",zLine,CMDFLAG_COMMAND);
552589
scan_for_func(zLine);
553590
scan_for_label("SETTING:",zLine,CMDFLAG_SETTING);
554591
scan_for_default(zLine);
592
+ scan_for_label("TOPIC:",zLine,CMDFLAG_TOPIC);
555593
}
556594
fclose(in);
557595
nUsed = nFixed;
558596
}
559597
560598
--- tools/mkindex.c
+++ tools/mkindex.c
@@ -17,15 +17,38 @@
17 **
18 ** This utility program scans Fossil source text looking for specially
19 ** formatted comments and generates C source code for constant tables
20 ** that define the behavior of commands, webpages, and settings.
21 **
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22 ** The source code is scanned for comment lines of the form:
23 **
24 ** WEBPAGE: /abc/xyz
25 ** COMMAND: cmdname
26 ** SETTING: access-log
 
27 **
28 ** The WEBPAGE and COMMAND comments should be followed by a function that
29 ** implements the webpage or command. The form of this function is:
30 **
31 ** void function_name(void){
@@ -75,10 +98,22 @@
75 ** SETTING: pgp-command
76 ** DEFAULT: gpg --clearsign -o
77 **
78 ** If no default is supplied, the default is assumed to be an empty string
79 ** or "off" in the case of a boolean.
 
 
 
 
 
 
 
 
 
 
 
 
80 */
81 #include <stdio.h>
82 #include <stdlib.h>
83 #include <assert.h>
84 #include <string.h>
@@ -85,26 +120,27 @@
85
86 /***************************************************************************
87 ** These macros must match similar macros in dispatch.c.
88 **
89 ** Allowed values for CmdOrPage.eCmdFlags. */
90 #define CMDFLAG_1ST_TIER 0x00001 /* Most important commands */
91 #define CMDFLAG_2ND_TIER 0x00002 /* Obscure and seldom used commands */
92 #define CMDFLAG_TEST 0x00004 /* Commands for testing only */
93 #define CMDFLAG_WEBPAGE 0x00008 /* Web pages */
94 #define CMDFLAG_COMMAND 0x00010 /* A command */
95 #define CMDFLAG_SETTING 0x00020 /* A setting */
96 #define CMDFLAG_VERSIONABLE 0x00040 /* A versionable setting */
97 #define CMDFLAG_BLOCKTEXT 0x00080 /* Multi-line text setting */
98 #define CMDFLAG_BOOLEAN 0x00100 /* A boolean setting */
99 #define CMDFLAG_RAWCONTENT 0x00200 /* Do not interpret webpage content */
100 #define CMDFLAG_SENSITIVE 0x00400 /* Security-sensitive setting */
101 #define CMDFLAG_HIDDEN 0x00800 /* Elide from most listings */
102 #define CMDFLAG_LDAVG_EXEMPT 0x01000 /* Exempt from load_control() */
103 #define CMDFLAG_ALIAS 0x02000 /* Command aliases */
104 #define CMDFLAG_KEEPEMPTY 0x04000 /* Do not unset empty settings */
105 #define CMDFLAG_ABBREVSUBCMD 0x08000 /* Abbreviated subcmd in help text */
 
106 /**************************************************************************/
107
108 /*
109 ** Each entry looks like this:
110 */
@@ -343,20 +379,21 @@
343 ** Scan a line for a function that implements a web page or command.
344 */
345 void scan_for_func(char *zLine){
346 int i,j,k;
347 char *z;
348 int isSetting;
349 if( nUsed<=nFixed ) return;
350 if( strncmp(zLine, "**", 2)==0
351 && fossil_isspace(zLine[2])
352 && strlen(zLine)<sizeof(zHelp)-nHelp-1
353 && nUsed>nFixed
354 && strncmp(zLine,"** COMMAND:",11)!=0
355 && strncmp(zLine,"** WEBPAGE:",11)!=0
356 && strncmp(zLine,"** SETTING:",11)!=0
357 && strncmp(zLine,"** DEFAULT:",11)!=0
 
358 ){
359 if( zLine[2]=='\n' ){
360 zHelp[nHelp++] = '\n';
361 }else{
362 if( strncmp(&zLine[3], "Usage: ", 6)==0 ) nHelp = 0;
@@ -365,12 +402,12 @@
365 }
366 return;
367 }
368 for(i=0; fossil_isspace(zLine[i]); i++){}
369 if( zLine[i]==0 ) return;
370 isSetting = (aEntry[nFixed].eType & CMDFLAG_SETTING)!=0;
371 if( !isSetting ){
372 if( strncmp(&zLine[i],"void",4)!=0 ){
373 if( zLine[i]!='*' ) goto page_skip;
374 return;
375 }
376 i += 4;
@@ -390,16 +427,16 @@
390 }else{
391 z = "";
392 }
393 for(k=nFixed; k<nUsed; k++){
394 aEntry[k].zIf = zIf[0] ? string_dup(zIf, -1) : 0;
395 aEntry[k].zFunc = isSetting ? "0" : string_dup(&zLine[i], j);
396 aEntry[k].zHelp = z;
397 z = 0;
398 aEntry[k].iHelp = nFixed;
399 }
400 if( !isSetting ){
401 i+=j;
402 while( fossil_isspace(zLine[i]) ){ i++; }
403 if( zLine[i]!='(' ) goto page_skip;
404 }
405 nFixed = nUsed;
@@ -442,11 +479,11 @@
442 "*/\n"
443 );
444
445 /* Output declarations for all the action functions */
446 for(i=0; i<nFixed; i++){
447 if( aEntry[i].eType & CMDFLAG_SETTING ) continue;
448 if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf);
449 printf("extern void %s(void);\n", aEntry[i].zFunc);
450 if( aEntry[i].zIf ) printf("#endif\n");
451 }
452
@@ -479,11 +516,11 @@
479 if( aEntry[i].zIf ){
480 printf("%s", aEntry[i].zIf);
481 }else if( (aEntry[i].eType & CMDFLAG_WEBPAGE)!=0 ){
482 nWeb++;
483 }
484 printf(" { \"%.*s\",%*s%s,%*szHelp%03d, %3d, 0x%03x },\n",
485 n, z,
486 25-n, "",
487 aEntry[i].zFunc,
488 (int)(29-strlen(aEntry[i].zFunc)), "",
489 aEntry[i].iHelp,
@@ -550,10 +587,11 @@
550 scan_for_label("WEBPAGE:",zLine,CMDFLAG_WEBPAGE);
551 scan_for_label("COMMAND:",zLine,CMDFLAG_COMMAND);
552 scan_for_func(zLine);
553 scan_for_label("SETTING:",zLine,CMDFLAG_SETTING);
554 scan_for_default(zLine);
 
555 }
556 fclose(in);
557 nUsed = nFixed;
558 }
559
560
--- tools/mkindex.c
+++ tools/mkindex.c
@@ -17,15 +17,38 @@
17 **
18 ** This utility program scans Fossil source text looking for specially
19 ** formatted comments and generates C source code for constant tables
20 ** that define the behavior of commands, webpages, and settings.
21 **
22 ** USAGE:
23 **
24 ** mkindex *.c >page_index.h
25 **
26 ** Run this command with arguments that are all input source files to
27 ** scan. Generated C code appears on standard output. The generated
28 ** C code includes structures that:
29 **
30 ** * Map command names to the C-language functions that implement
31 ** those command.
32 **
33 ** * Map webpage names to the C-language functions that implement
34 ** those web pages.
35 **
36 ** * Map settings into attributes, such as they default value for
37 ** each setting, and the kind of value (boolean, multi-line, etc).
38 **
39 ** * Provide help text for commands, webpages, settings, and other
40 ** miscellanous help topics.
41 **
42 ** COMMENT TEXT THAT THIS PROGRAM LOOKS FOR:
43 **
44 ** The source code is scanned for comment lines of the form:
45 **
46 ** WEBPAGE: /abc/xyz
47 ** COMMAND: cmdname
48 ** SETTING: access-log
49 ** TOPIC: help-topic
50 **
51 ** The WEBPAGE and COMMAND comments should be followed by a function that
52 ** implements the webpage or command. The form of this function is:
53 **
54 ** void function_name(void){
@@ -75,10 +98,22 @@
98 ** SETTING: pgp-command
99 ** DEFAULT: gpg --clearsign -o
100 **
101 ** If no default is supplied, the default is assumed to be an empty string
102 ** or "off" in the case of a boolean.
103 **
104 ** A TOPIC: is followed by help text for the named topic.
105 **
106 ** OUTPUTS:
107 **
108 ** The output is C-language text to define and initialize a constant
109 ** array of CmdOrPage objects named "aCommand[]". That array is a global
110 ** variable. The dispatch.c source file defines the CmdOrPage object and
111 ** deals with the aCommand[] global variable.
112 **
113 ** The output also contains a constant array of Setting objects named
114 ** aSetting[]. The Setting object is defined in db.c.
115 */
116 #include <stdio.h>
117 #include <stdlib.h>
118 #include <assert.h>
119 #include <string.h>
@@ -85,26 +120,27 @@
120
121 /***************************************************************************
122 ** These macros must match similar macros in dispatch.c.
123 **
124 ** Allowed values for CmdOrPage.eCmdFlags. */
125 #define CMDFLAG_1ST_TIER 0x000001 /* Most important commands */
126 #define CMDFLAG_2ND_TIER 0x000002 /* Obscure and seldom used commands */
127 #define CMDFLAG_TEST 0x000004 /* Commands for testing only */
128 #define CMDFLAG_WEBPAGE 0x000008 /* Web pages */
129 #define CMDFLAG_COMMAND 0x000010 /* A command */
130 #define CMDFLAG_SETTING 0x000020 /* A setting */
131 #define CMDFLAG_VERSIONABLE 0x000040 /* A versionable setting */
132 #define CMDFLAG_BLOCKTEXT 0x000080 /* Multi-line text setting */
133 #define CMDFLAG_BOOLEAN 0x000100 /* A boolean setting */
134 #define CMDFLAG_RAWCONTENT 0x000200 /* Do not interpret webpage content */
135 #define CMDFLAG_SENSITIVE 0x000400 /* Security-sensitive setting */
136 #define CMDFLAG_HIDDEN 0x000800 /* Elide from most listings */
137 #define CMDFLAG_LDAVG_EXEMPT 0x001000 /* Exempt from load_control() */
138 #define CMDFLAG_ALIAS 0x002000 /* Command aliases */
139 #define CMDFLAG_KEEPEMPTY 0x004000 /* Do not unset empty settings */
140 #define CMDFLAG_ABBREVSUBCMD 0x008000 /* Abbreviated subcmd in help text */
141 #define CMDFLAG_TOPIC 0x010000 /* A help topic */
142 /**************************************************************************/
143
144 /*
145 ** Each entry looks like this:
146 */
@@ -343,20 +379,21 @@
379 ** Scan a line for a function that implements a web page or command.
380 */
381 void scan_for_func(char *zLine){
382 int i,j,k;
383 char *z;
384 int hasFunc;
385 if( nUsed<=nFixed ) return;
386 if( strncmp(zLine, "**", 2)==0
387 && fossil_isspace(zLine[2])
388 && strlen(zLine)<sizeof(zHelp)-nHelp-1
389 && nUsed>nFixed
390 && strncmp(zLine,"** COMMAND:",11)!=0
391 && strncmp(zLine,"** WEBPAGE:",11)!=0
392 && strncmp(zLine,"** SETTING:",11)!=0
393 && strncmp(zLine,"** DEFAULT:",11)!=0
394 && strncmp(zLine,"** TOPIC:",9)!=0
395 ){
396 if( zLine[2]=='\n' ){
397 zHelp[nHelp++] = '\n';
398 }else{
399 if( strncmp(&zLine[3], "Usage: ", 6)==0 ) nHelp = 0;
@@ -365,12 +402,12 @@
402 }
403 return;
404 }
405 for(i=0; fossil_isspace(zLine[i]); i++){}
406 if( zLine[i]==0 ) return;
407 hasFunc = (aEntry[nFixed].eType & (CMDFLAG_SETTING|CMDFLAG_TOPIC))==0;
408 if( hasFunc ){
409 if( strncmp(&zLine[i],"void",4)!=0 ){
410 if( zLine[i]!='*' ) goto page_skip;
411 return;
412 }
413 i += 4;
@@ -390,16 +427,16 @@
427 }else{
428 z = "";
429 }
430 for(k=nFixed; k<nUsed; k++){
431 aEntry[k].zIf = zIf[0] ? string_dup(zIf, -1) : 0;
432 aEntry[k].zFunc = hasFunc ? string_dup(&zLine[i], j) : "0";
433 aEntry[k].zHelp = z;
434 z = 0;
435 aEntry[k].iHelp = nFixed;
436 }
437 if( hasFunc ){
438 i+=j;
439 while( fossil_isspace(zLine[i]) ){ i++; }
440 if( zLine[i]!='(' ) goto page_skip;
441 }
442 nFixed = nUsed;
@@ -442,11 +479,11 @@
479 "*/\n"
480 );
481
482 /* Output declarations for all the action functions */
483 for(i=0; i<nFixed; i++){
484 if( aEntry[i].eType & (CMDFLAG_SETTING|CMDFLAG_TOPIC) ) continue;
485 if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf);
486 printf("extern void %s(void);\n", aEntry[i].zFunc);
487 if( aEntry[i].zIf ) printf("#endif\n");
488 }
489
@@ -479,11 +516,11 @@
516 if( aEntry[i].zIf ){
517 printf("%s", aEntry[i].zIf);
518 }else if( (aEntry[i].eType & CMDFLAG_WEBPAGE)!=0 ){
519 nWeb++;
520 }
521 printf(" { \"%.*s\",%*s%s,%*szHelp%03d, %3d, 0x%05x },\n",
522 n, z,
523 25-n, "",
524 aEntry[i].zFunc,
525 (int)(29-strlen(aEntry[i].zFunc)), "",
526 aEntry[i].iHelp,
@@ -550,10 +587,11 @@
587 scan_for_label("WEBPAGE:",zLine,CMDFLAG_WEBPAGE);
588 scan_for_label("COMMAND:",zLine,CMDFLAG_COMMAND);
589 scan_for_func(zLine);
590 scan_for_label("SETTING:",zLine,CMDFLAG_SETTING);
591 scan_for_default(zLine);
592 scan_for_label("TOPIC:",zLine,CMDFLAG_TOPIC);
593 }
594 fclose(in);
595 nUsed = nFixed;
596 }
597
598

Keyboard Shortcuts

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