Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Teach the help command and /help page to be able to distinguish completely unknown commands from commands which are only conditionally available depending on their platform or build flags. Based on a /chat discussion. |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
e5ace41107d6312366f365cc1a70d1c1 |
| User & Date: | stephan 2025-03-10 10:21:50.351 |
Context
|
2025-03-10
| ||
| 10:23 | Make the (help platform-specific-command-or-page) output more generic so that it applies equally to commands, settings, and web pages. check-in: 7919a44d53 user: stephan tags: trunk | |
| 10:21 | Teach the help command and /help page to be able to distinguish completely unknown commands from commands which are only conditionally available depending on their platform or build flags. Based on a /chat discussion. check-in: e5ace41107 user: stephan tags: trunk | |
| 09:55 | In help texts, mention that 'winsrv' is only available on Windows. check-in: e2c161bafb user: danield tags: trunk | |
Changes
Changes to src/dispatch.c.
| ︙ | ︙ | |||
809 810 811 812 813 814 815 816 817 818 819 820 821 822 |
n = dispatch_approx_match(g.argv[i], 20, az);
for(j=0; j<n; j++){
fossil_print(" %s\n", az[j]);
}
}
}
/*
** WEBPAGE: help
** URL: /help?name=CMD
**
** Show the built-in help text for CMD. CMD can be a command-line interface
** command or a page name from the web interface or a setting.
** Query parameters:
| > > > > > > > > > > > > > > > > > > > > > > | 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 |
n = dispatch_approx_match(g.argv[i], 20, az);
for(j=0; j<n; j++){
fossil_print(" %s\n", az[j]);
}
}
}
/*
** Returns 1 if the command or page name zName is known to be a
** command/page which is only available in certain builds/platforms,
** else returns 0.
*/
static int help_is_platform_command(const char *zName){
const char *aList[] = {
/* List of commands/pages which are known to only be available in
** certain builds/platforms. */
"winsrv",
"json", "/json",
NULL /* end-of-list sentinel */
};
int i = 0;
const char *z;
for( z = aList[0]; z ; z = aList[++i] ){
if( 0==fossil_strcmp(zName, z) ) return 1;
}
return 0;
}
/*
** WEBPAGE: help
** URL: /help?name=CMD
**
** Show the built-in help text for CMD. CMD can be a command-line interface
** command or a page name from the web interface or a setting.
** Query parameters:
|
| ︙ | ︙ | |||
858 859 860 861 862 863 864 |
@ <h1>The "%h(pCmd->zName)" page:</h1>
}else if( rc==0 && (pCmd->eCmdFlags & CMDFLAG_SETTING)!=0 ){
@ <h1>The "%h(pCmd->zName)" setting:</h1>
}else{
@ <h1>The "%h(pCmd->zName)" command:</h1>
}
if( rc==1 || (rc==2 && zCmd[0]=='/') ){
| > > > | > | 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 |
@ <h1>The "%h(pCmd->zName)" page:</h1>
}else if( rc==0 && (pCmd->eCmdFlags & CMDFLAG_SETTING)!=0 ){
@ <h1>The "%h(pCmd->zName)" setting:</h1>
}else{
@ <h1>The "%h(pCmd->zName)" command:</h1>
}
if( rc==1 || (rc==2 && zCmd[0]=='/') ){
if( zCmd && help_is_platform_command(zCmd) ){
@ Not available in this build: "%h(zCmd)"
}else{
@ Unknown topic: "%h(zCmd)"
}
}else if( rc==2 ){
@ Ambiguous prefix: "%h(zCmd)"
}else{
if( pCmd->zHelp[0]==0 ){
@ No help available for "%h(pCmd->zName)"
}else if( P("plaintext") ){
Blob txt;
|
| ︙ | ︙ | |||
1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 |
zCmdOrPage = "command or setting";
}
rc = dispatch_name_search(g.argv[2], mask|CMDFLAG_PREFIX, &pCmd);
if( rc ){
int i, n;
const char *az[5];
if( rc==1 ){
fossil_print("unknown %s: %s\n", zCmdOrPage, g.argv[2]);
}else{
fossil_print("ambiguous %s prefix: %s\n",
zCmdOrPage, g.argv[2]);
}
fossil_print("Did you mean one of these TOPICs:\n");
n = dispatch_approx_match(g.argv[2], 5, az);
| > > > > | 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 |
zCmdOrPage = "command or setting";
}
rc = dispatch_name_search(g.argv[2], mask|CMDFLAG_PREFIX, &pCmd);
if( rc ){
int i, n;
const char *az[5];
if( rc==1 ){
if( help_is_platform_command(g.argv[2]) ){
fossil_print("Command is not available in this build: %s\n", g.argv[2]);
return;
}
fossil_print("unknown %s: %s\n", zCmdOrPage, g.argv[2]);
}else{
fossil_print("ambiguous %s prefix: %s\n",
zCmdOrPage, g.argv[2]);
}
fossil_print("Did you mean one of these TOPICs:\n");
n = dispatch_approx_match(g.argv[2], 5, az);
|
| ︙ | ︙ |