Fossil SCM
CLI help command now (cosmetically) differentiates between pages and commands.
Commit
5be5933348f138a3b6d295ad226212f906e1ef04
Parent
aa5def064dc3062…
1 file changed
+18
-7
+18
-7
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -972,12 +972,14 @@ | ||
| 972 | 972 | ** %fossil help --test Show test commands only |
| 973 | 973 | ** %fossil help --aux Show auxiliary commands only |
| 974 | 974 | ** %fossil help --www Show list of WWW pages |
| 975 | 975 | */ |
| 976 | 976 | void help_cmd(void){ |
| 977 | - int rc, idx; | |
| 977 | + int rc, idx, isPage = 0; | |
| 978 | 978 | const char *z; |
| 979 | + char const * zCmdOrPage; | |
| 980 | + char const * zCmdOrPagePlural; | |
| 979 | 981 | if( g.argc<3 ){ |
| 980 | 982 | z = g.argv[0]; |
| 981 | 983 | fossil_print( |
| 982 | 984 | "Usage: %s help COMMAND\n" |
| 983 | 985 | "Common COMMANDs: (use \"%s help --all\" for a complete list)\n", |
| @@ -999,26 +1001,35 @@ | ||
| 999 | 1001 | return; |
| 1000 | 1002 | } |
| 1001 | 1003 | else if( find_option("test",0,0) ){ |
| 1002 | 1004 | command_list(0, CMDFLAG_TEST); |
| 1003 | 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"; | |
| 1004 | 1014 | } |
| 1005 | 1015 | rc = name_search(g.argv[2], aCommand, count(aCommand), &idx); |
| 1006 | 1016 | 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)); | |
| 1009 | 1020 | fossil_exit(1); |
| 1010 | 1021 | }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); | |
| 1013 | 1024 | command_list(g.argv[2], 0xff); |
| 1014 | 1025 | fossil_exit(1); |
| 1015 | 1026 | } |
| 1016 | 1027 | z = aCmdHelp[idx].zText; |
| 1017 | 1028 | 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); | |
| 1020 | 1031 | } |
| 1021 | 1032 | while( *z ){ |
| 1022 | 1033 | if( *z=='%' && strncmp(z, "%fossil", 7)==0 ){ |
| 1023 | 1034 | fossil_print("%s", g.argv[0]); |
| 1024 | 1035 | z += 7; |
| 1025 | 1036 |
| --- 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 |