Fossil SCM

CLI help command now (cosmetically) differentiates between pages and commands.

stephan 2013-02-21 19:41 UTC help-www
Commit 5be5933348f138a3b6d295ad226212f906e1ef04
1 file changed +18 -7
+18 -7
--- src/main.c
+++ src/main.c
@@ -972,12 +972,14 @@
972972
** %fossil help --test Show test commands only
973973
** %fossil help --aux Show auxiliary commands only
974974
** %fossil help --www Show list of WWW pages
975975
*/
976976
void help_cmd(void){
977
- int rc, idx;
977
+ int rc, idx, isPage = 0;
978978
const char *z;
979
+ char const * zCmdOrPage;
980
+ char const * zCmdOrPagePlural;
979981
if( g.argc<3 ){
980982
z = g.argv[0];
981983
fossil_print(
982984
"Usage: %s help COMMAND\n"
983985
"Common COMMANDs: (use \"%s help --all\" for a complete list)\n",
@@ -999,26 +1001,35 @@
9991001
return;
10001002
}
10011003
else if( find_option("test",0,0) ){
10021004
command_list(0, CMDFLAG_TEST);
10031005
return;
1006
+ }
1007
+ isPage = ('/' == *g.argv[2]) ? 1 : 0;
1008
+ if(isPage){
1009
+ zCmdOrPage = "page";
1010
+ zCmdOrPagePlural = "pages";
1011
+ }else{
1012
+ zCmdOrPage = "command";
1013
+ zCmdOrPagePlural = "commands";
10041014
}
10051015
rc = name_search(g.argv[2], aCommand, count(aCommand), &idx);
10061016
if( rc==1 ){
1007
- fossil_print("unknown command: %s\nAvailable commands:\n", g.argv[2]);
1008
- command_list(0, 0xff & ~CMDFLAG_WEBPAGE);
1017
+ fossil_print("unknown %s: %s\nAvailable %s:\n",
1018
+ zCmdOrPage, g.argv[2], zCmdOrPagePlural);
1019
+ command_list(0, isPage ? CMDFLAG_WEBPAGE : (0xff & ~CMDFLAG_WEBPAGE));
10091020
fossil_exit(1);
10101021
}else if( rc==2 ){
1011
- fossil_print("ambiguous command prefix: %s\nMatching commands:\n",
1012
- g.argv[2]);
1022
+ fossil_print("ambiguous %s prefix: %s\nMatching %s:\n",
1023
+ zCmdOrPage, g.argv[2], zCmdOrPagePlural);
10131024
command_list(g.argv[2], 0xff);
10141025
fossil_exit(1);
10151026
}
10161027
z = aCmdHelp[idx].zText;
10171028
if( z==0 ){
1018
- fossil_fatal("no help available for the %s command",
1019
- aCommand[idx].zName);
1029
+ fossil_fatal("no help available for the %s %s",
1030
+ aCommand[idx].zName, zCmdOrPage);
10201031
}
10211032
while( *z ){
10221033
if( *z=='%' && strncmp(z, "%fossil", 7)==0 ){
10231034
fossil_print("%s", g.argv[0]);
10241035
z += 7;
10251036
--- src/main.c
+++ src/main.c
@@ -972,12 +972,14 @@
972 ** %fossil help --test Show test commands only
973 ** %fossil help --aux Show auxiliary commands only
974 ** %fossil help --www Show list of WWW pages
975 */
976 void help_cmd(void){
977 int rc, idx;
978 const char *z;
 
 
979 if( g.argc<3 ){
980 z = g.argv[0];
981 fossil_print(
982 "Usage: %s help COMMAND\n"
983 "Common COMMANDs: (use \"%s help --all\" for a complete list)\n",
@@ -999,26 +1001,35 @@
999 return;
1000 }
1001 else if( find_option("test",0,0) ){
1002 command_list(0, CMDFLAG_TEST);
1003 return;
 
 
 
 
 
 
 
 
1004 }
1005 rc = name_search(g.argv[2], aCommand, count(aCommand), &idx);
1006 if( rc==1 ){
1007 fossil_print("unknown command: %s\nAvailable commands:\n", g.argv[2]);
1008 command_list(0, 0xff & ~CMDFLAG_WEBPAGE);
 
1009 fossil_exit(1);
1010 }else if( rc==2 ){
1011 fossil_print("ambiguous command prefix: %s\nMatching commands:\n",
1012 g.argv[2]);
1013 command_list(g.argv[2], 0xff);
1014 fossil_exit(1);
1015 }
1016 z = aCmdHelp[idx].zText;
1017 if( z==0 ){
1018 fossil_fatal("no help available for the %s command",
1019 aCommand[idx].zName);
1020 }
1021 while( *z ){
1022 if( *z=='%' && strncmp(z, "%fossil", 7)==0 ){
1023 fossil_print("%s", g.argv[0]);
1024 z += 7;
1025
--- src/main.c
+++ src/main.c
@@ -972,12 +972,14 @@
972 ** %fossil help --test Show test commands only
973 ** %fossil help --aux Show auxiliary commands only
974 ** %fossil help --www Show list of WWW pages
975 */
976 void help_cmd(void){
977 int rc, idx, isPage = 0;
978 const char *z;
979 char const * zCmdOrPage;
980 char const * zCmdOrPagePlural;
981 if( g.argc<3 ){
982 z = g.argv[0];
983 fossil_print(
984 "Usage: %s help COMMAND\n"
985 "Common COMMANDs: (use \"%s help --all\" for a complete list)\n",
@@ -999,26 +1001,35 @@
1001 return;
1002 }
1003 else if( find_option("test",0,0) ){
1004 command_list(0, CMDFLAG_TEST);
1005 return;
1006 }
1007 isPage = ('/' == *g.argv[2]) ? 1 : 0;
1008 if(isPage){
1009 zCmdOrPage = "page";
1010 zCmdOrPagePlural = "pages";
1011 }else{
1012 zCmdOrPage = "command";
1013 zCmdOrPagePlural = "commands";
1014 }
1015 rc = name_search(g.argv[2], aCommand, count(aCommand), &idx);
1016 if( rc==1 ){
1017 fossil_print("unknown %s: %s\nAvailable %s:\n",
1018 zCmdOrPage, g.argv[2], zCmdOrPagePlural);
1019 command_list(0, isPage ? CMDFLAG_WEBPAGE : (0xff & ~CMDFLAG_WEBPAGE));
1020 fossil_exit(1);
1021 }else if( rc==2 ){
1022 fossil_print("ambiguous %s prefix: %s\nMatching %s:\n",
1023 zCmdOrPage, g.argv[2], zCmdOrPagePlural);
1024 command_list(g.argv[2], 0xff);
1025 fossil_exit(1);
1026 }
1027 z = aCmdHelp[idx].zText;
1028 if( z==0 ){
1029 fossil_fatal("no help available for the %s %s",
1030 aCommand[idx].zName, zCmdOrPage);
1031 }
1032 while( *z ){
1033 if( *z=='%' && strncmp(z, "%fossil", 7)==0 ){
1034 fossil_print("%s", g.argv[0]);
1035 z += 7;
1036

Keyboard Shortcuts

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