Fossil

Check-in [5be5933348]
Login

Check-in [5be5933348]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:CLI help command now (cosmetically) differentiates between pages and commands.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | help-www
Files: files | file ages | folders
SHA1: 5be5933348f138a3b6d295ad226212f906e1ef04
User & Date: stephan 2013-02-21 19:41:13.222
Context
2013-02-22
17:34
merged in [help-www] branch: adds help support for /www/pages. ... (check-in: b38bb4f9bd user: stephan tags: trunk)
2013-02-21
19:41
CLI help command now (cosmetically) differentiates between pages and commands. ... (Closed-Leaf check-in: 5be5933348 user: stephan tags: help-www)
09:57
/help now removes the leading slashes from the page list (looks cleaner). /help?cmd=foo now shows a different label for pages and commands (differentiates based on existence of leading /). ... (check-in: aa5def064d user: stephan tags: help-www)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/main.c.
970
971
972
973
974
975
976
977
978


979
980
981
982
983
984
985
**    %fossil help              Show common commands
**    %fossil help --all        Show both common and auxiliary commands
**    %fossil help --test       Show test commands only
**    %fossil help --aux        Show auxiliary commands only
**    %fossil help --www        Show list of WWW pages
*/
void help_cmd(void){
  int rc, idx;
  const char *z;


  if( g.argc<3 ){
    z = g.argv[0];
    fossil_print(
      "Usage: %s help COMMAND\n"
      "Common COMMANDs:  (use \"%s help --all\" for a complete list)\n",
      z, z);
    command_list(0, CMDFLAG_1ST_TIER);







|

>
>







970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
**    %fossil help              Show common commands
**    %fossil help --all        Show both common and auxiliary commands
**    %fossil help --test       Show test commands only
**    %fossil help --aux        Show auxiliary commands only
**    %fossil help --www        Show list of WWW pages
*/
void help_cmd(void){
  int rc, idx, isPage = 0;
  const char *z;
  char const * zCmdOrPage;
  char const * zCmdOrPagePlural;
  if( g.argc<3 ){
    z = g.argv[0];
    fossil_print(
      "Usage: %s help COMMAND\n"
      "Common COMMANDs:  (use \"%s help --all\" for a complete list)\n",
      z, z);
    command_list(0, CMDFLAG_1ST_TIER);
997
998
999
1000
1001
1002
1003








1004
1005
1006
1007

1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
  else if( find_option("aux",0,0) ){
    command_list(0, CMDFLAG_2ND_TIER);
    return;
  }
  else if( find_option("test",0,0) ){
    command_list(0, CMDFLAG_TEST);
    return;








  }
  rc = name_search(g.argv[2], aCommand, count(aCommand), &idx);
  if( rc==1 ){
    fossil_print("unknown command: %s\nAvailable commands:\n", g.argv[2]);

    command_list(0, 0xff & ~CMDFLAG_WEBPAGE);
    fossil_exit(1);
  }else if( rc==2 ){
    fossil_print("ambiguous command prefix: %s\nMatching commands:\n",
                 g.argv[2]);
    command_list(g.argv[2], 0xff);
    fossil_exit(1);
  }
  z = aCmdHelp[idx].zText;
  if( z==0 ){
    fossil_fatal("no help available for the %s command",
       aCommand[idx].zName);
  }
  while( *z ){
    if( *z=='%' && strncmp(z, "%fossil", 7)==0 ){
      fossil_print("%s", g.argv[0]);
      z += 7;
    }else{
      putchar(*z);







>
>
>
>
>
>
>
>



|
>
|


|
|





|
|







999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
  else if( find_option("aux",0,0) ){
    command_list(0, CMDFLAG_2ND_TIER);
    return;
  }
  else if( find_option("test",0,0) ){
    command_list(0, CMDFLAG_TEST);
    return;
  }
  isPage = ('/' == *g.argv[2]) ? 1 : 0;
  if(isPage){
    zCmdOrPage = "page";
    zCmdOrPagePlural = "pages";
  }else{
    zCmdOrPage = "command";
    zCmdOrPagePlural = "commands";
  }
  rc = name_search(g.argv[2], aCommand, count(aCommand), &idx);
  if( rc==1 ){
    fossil_print("unknown %s: %s\nAvailable %s:\n",
                 zCmdOrPage, g.argv[2], zCmdOrPagePlural);
    command_list(0, isPage ? CMDFLAG_WEBPAGE : (0xff & ~CMDFLAG_WEBPAGE));
    fossil_exit(1);
  }else if( rc==2 ){
    fossil_print("ambiguous %s prefix: %s\nMatching %s:\n",
                 zCmdOrPage, g.argv[2], zCmdOrPagePlural);
    command_list(g.argv[2], 0xff);
    fossil_exit(1);
  }
  z = aCmdHelp[idx].zText;
  if( z==0 ){
    fossil_fatal("no help available for the %s %s",
                 aCommand[idx].zName, zCmdOrPage);
  }
  while( *z ){
    if( *z=='%' && strncmp(z, "%fossil", 7)==0 ){
      fossil_print("%s", g.argv[0]);
      z += 7;
    }else{
      putchar(*z);