Fossil SCM
added command line help page to the gui
Commit
ffbfb4d57c7d40da4598ab34e8afc7f19ef853ff
Parent
720fa53d1f2ceeb…
1 file changed
+50
+50
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -591,10 +591,60 @@ | ||
| 591 | 591 | z++; |
| 592 | 592 | } |
| 593 | 593 | } |
| 594 | 594 | putchar('\n'); |
| 595 | 595 | } |
| 596 | + | |
| 597 | +/* | |
| 598 | +** WEBPAGE: help | |
| 599 | +** URL: /help?cmd=CMD | |
| 600 | +*/ | |
| 601 | +void help_page(void){ | |
| 602 | + const char * zCmd = P("cmd"); | |
| 603 | + | |
| 604 | + style_header("Command line help %s%s",zCmd?" - ":"",zCmd?zCmd:""); | |
| 605 | + if( zCmd ){ | |
| 606 | + int rc, idx; | |
| 607 | + char *z, *s, *d; | |
| 608 | + | |
| 609 | + @ <h1>%s(zCmd)</h1> | |
| 610 | + rc = name_search(zCmd, aCommand, count(aCommand), &idx); | |
| 611 | + if( rc==1 ){ | |
| 612 | + @ unknown command: %s(zCmd) | |
| 613 | + }else if( rc==2 ){ | |
| 614 | + @ ambiguous command prefix: %s(zCmd) | |
| 615 | + }else{ | |
| 616 | + z = (char*)aCmdHelp[idx]; | |
| 617 | + if( s==0 ){ | |
| 618 | + @ no help available for the %s(aCommand[idx].zName) command | |
| 619 | + }else{ | |
| 620 | + z=s=d=mprintf("%s",z); | |
| 621 | + while( *s ){ | |
| 622 | + if( *s=='%' && strncmp(s, "%fossil", 7)==0 ){ | |
| 623 | + s++; | |
| 624 | + }else{ | |
| 625 | + *d++ = *s++; | |
| 626 | + } | |
| 627 | + } | |
| 628 | + *d = 0; | |
| 629 | + @ <pre>%s(z)</pre> | |
| 630 | + free(z); | |
| 631 | + } | |
| 632 | + } | |
| 633 | + @ <hr/><a href="help">available commands</a> in fossil version %s(MANIFEST_VERSION" "MANIFEST_DATE) UTC | |
| 634 | + }else{ | |
| 635 | + int i; | |
| 636 | + | |
| 637 | + @ <h1>Available commands</h1> | |
| 638 | + for(i=0; i<count(aCommand); i++){ | |
| 639 | + if( strncmp(aCommand[i].zName,"test",4)==0 ) continue; | |
| 640 | + @ <kbd><a href="help?cmd=%s(aCommand[i].zName)">%s(aCommand[i].zName)</a></kbd> | |
| 641 | + } | |
| 642 | + @ <hr/>fossil version %s(MANIFEST_VERSION" "MANIFEST_DATE) UTC | |
| 643 | + } | |
| 644 | + style_footer(); | |
| 645 | +} | |
| 596 | 646 | |
| 597 | 647 | /* |
| 598 | 648 | ** Set the g.zBaseURL value to the full URL for the toplevel of |
| 599 | 649 | ** the fossil tree. Set g.zTop to g.zBaseURL without the |
| 600 | 650 | ** leading "http://" and the host and port. |
| 601 | 651 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -591,10 +591,60 @@ | |
| 591 | z++; |
| 592 | } |
| 593 | } |
| 594 | putchar('\n'); |
| 595 | } |
| 596 | |
| 597 | /* |
| 598 | ** Set the g.zBaseURL value to the full URL for the toplevel of |
| 599 | ** the fossil tree. Set g.zTop to g.zBaseURL without the |
| 600 | ** leading "http://" and the host and port. |
| 601 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -591,10 +591,60 @@ | |
| 591 | z++; |
| 592 | } |
| 593 | } |
| 594 | putchar('\n'); |
| 595 | } |
| 596 | |
| 597 | /* |
| 598 | ** WEBPAGE: help |
| 599 | ** URL: /help?cmd=CMD |
| 600 | */ |
| 601 | void help_page(void){ |
| 602 | const char * zCmd = P("cmd"); |
| 603 | |
| 604 | style_header("Command line help %s%s",zCmd?" - ":"",zCmd?zCmd:""); |
| 605 | if( zCmd ){ |
| 606 | int rc, idx; |
| 607 | char *z, *s, *d; |
| 608 | |
| 609 | @ <h1>%s(zCmd)</h1> |
| 610 | rc = name_search(zCmd, aCommand, count(aCommand), &idx); |
| 611 | if( rc==1 ){ |
| 612 | @ unknown command: %s(zCmd) |
| 613 | }else if( rc==2 ){ |
| 614 | @ ambiguous command prefix: %s(zCmd) |
| 615 | }else{ |
| 616 | z = (char*)aCmdHelp[idx]; |
| 617 | if( s==0 ){ |
| 618 | @ no help available for the %s(aCommand[idx].zName) command |
| 619 | }else{ |
| 620 | z=s=d=mprintf("%s",z); |
| 621 | while( *s ){ |
| 622 | if( *s=='%' && strncmp(s, "%fossil", 7)==0 ){ |
| 623 | s++; |
| 624 | }else{ |
| 625 | *d++ = *s++; |
| 626 | } |
| 627 | } |
| 628 | *d = 0; |
| 629 | @ <pre>%s(z)</pre> |
| 630 | free(z); |
| 631 | } |
| 632 | } |
| 633 | @ <hr/><a href="help">available commands</a> in fossil version %s(MANIFEST_VERSION" "MANIFEST_DATE) UTC |
| 634 | }else{ |
| 635 | int i; |
| 636 | |
| 637 | @ <h1>Available commands</h1> |
| 638 | for(i=0; i<count(aCommand); i++){ |
| 639 | if( strncmp(aCommand[i].zName,"test",4)==0 ) continue; |
| 640 | @ <kbd><a href="help?cmd=%s(aCommand[i].zName)">%s(aCommand[i].zName)</a></kbd> |
| 641 | } |
| 642 | @ <hr/>fossil version %s(MANIFEST_VERSION" "MANIFEST_DATE) UTC |
| 643 | } |
| 644 | style_footer(); |
| 645 | } |
| 646 | |
| 647 | /* |
| 648 | ** Set the g.zBaseURL value to the full URL for the toplevel of |
| 649 | ** the fossil tree. Set g.zTop to g.zBaseURL without the |
| 650 | ** leading "http://" and the host and port. |
| 651 |