| | @@ -730,14 +730,17 @@ |
| 730 | 730 | ** |
| 731 | 731 | ** List all web pages |
| 732 | 732 | */ |
| 733 | 733 | void cmd_test_webpage_list(void){ |
| 734 | 734 | int i, nCmd; |
| 735 | | - const char *aCmd[count(aWebpage)]; |
| 736 | | - for(i=nCmd=0; i<count(aWebpage); i++){ |
| 737 | | - aCmd[nCmd++] = aWebpage[i].zName; |
| 735 | + const char *aCmd[count(aCommand)]; |
| 736 | + for(i=nCmd=0; i<count(aCommand); i++){ |
| 737 | + if(0x08 & aCommand[i].cmdFlags){ |
| 738 | + aCmd[nCmd++] = aWebpage[i].zName; |
| 739 | + } |
| 738 | 740 | } |
| 741 | + assert(nCmd && "page list is empty?"); |
| 739 | 742 | multi_column_list(aCmd, nCmd); |
| 740 | 743 | } |
| 741 | 744 | |
| 742 | 745 | /* |
| 743 | 746 | ** COMMAND: version |
| | @@ -763,14 +766,17 @@ |
| 763 | 766 | ** |
| 764 | 767 | ** %fossil help Show common commands |
| 765 | 768 | ** %fossil help --all Show both common and auxiliary commands |
| 766 | 769 | ** %fossil help --test Show test commands only |
| 767 | 770 | ** %fossil help --aux Show auxiliary commands only |
| 771 | +** %fossil help --www Show list of WWW pages |
| 768 | 772 | */ |
| 769 | 773 | void help_cmd(void){ |
| 770 | | - int rc, idx; |
| 774 | + int rc, idx, isPage = 0; |
| 771 | 775 | const char *z; |
| 776 | + char const * zCmdOrPage; |
| 777 | + char const * zCmdOrPagePlural; |
| 772 | 778 | if( g.argc<3 ){ |
| 773 | 779 | z = g.argv[0]; |
| 774 | 780 | fossil_print( |
| 775 | 781 | "Usage: %s help COMMAND\n" |
| 776 | 782 | "Common COMMANDs: (use \"%s help --all\" for a complete list)\n", |
| | @@ -781,33 +787,46 @@ |
| 781 | 787 | } |
| 782 | 788 | if( find_option("all",0,0) ){ |
| 783 | 789 | command_list(0, CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER); |
| 784 | 790 | return; |
| 785 | 791 | } |
| 786 | | - if( find_option("aux",0,0) ){ |
| 792 | + else if( find_option("www",0,0) ){ |
| 793 | + command_list(0, CMDFLAG_WEBPAGE); |
| 794 | + return; |
| 795 | + } |
| 796 | + else if( find_option("aux",0,0) ){ |
| 787 | 797 | command_list(0, CMDFLAG_2ND_TIER); |
| 788 | 798 | return; |
| 789 | 799 | } |
| 790 | | - if( find_option("test",0,0) ){ |
| 800 | + else if( find_option("test",0,0) ){ |
| 791 | 801 | command_list(0, CMDFLAG_TEST); |
| 792 | 802 | return; |
| 803 | + } |
| 804 | + isPage = ('/' == *g.argv[2]) ? 1 : 0; |
| 805 | + if(isPage){ |
| 806 | + zCmdOrPage = "page"; |
| 807 | + zCmdOrPagePlural = "pages"; |
| 808 | + }else{ |
| 809 | + zCmdOrPage = "command"; |
| 810 | + zCmdOrPagePlural = "commands"; |
| 793 | 811 | } |
| 794 | 812 | rc = name_search(g.argv[2], aCommand, count(aCommand), &idx); |
| 795 | 813 | if( rc==1 ){ |
| 796 | | - fossil_print("unknown command: %s\nAvailable commands:\n", g.argv[2]); |
| 797 | | - command_list(0, 0xff); |
| 814 | + fossil_print("unknown %s: %s\nAvailable %s:\n", |
| 815 | + zCmdOrPage, g.argv[2], zCmdOrPagePlural); |
| 816 | + command_list(0, isPage ? CMDFLAG_WEBPAGE : (0xff & ~CMDFLAG_WEBPAGE)); |
| 798 | 817 | fossil_exit(1); |
| 799 | 818 | }else if( rc==2 ){ |
| 800 | | - fossil_print("ambiguous command prefix: %s\nMatching commands:\n", |
| 801 | | - g.argv[2]); |
| 819 | + fossil_print("ambiguous %s prefix: %s\nMatching %s:\n", |
| 820 | + zCmdOrPage, g.argv[2], zCmdOrPagePlural); |
| 802 | 821 | command_list(g.argv[2], 0xff); |
| 803 | 822 | fossil_exit(1); |
| 804 | 823 | } |
| 805 | | - z = aCmdHelp[idx]; |
| 824 | + z = aCmdHelp[idx].zText; |
| 806 | 825 | if( z==0 ){ |
| 807 | | - fossil_fatal("no help available for the %s command", |
| 808 | | - aCommand[idx].zName); |
| 826 | + fossil_fatal("no help available for the %s %s", |
| 827 | + aCommand[idx].zName, zCmdOrPage); |
| 809 | 828 | } |
| 810 | 829 | while( *z ){ |
| 811 | 830 | if( *z=='%' && strncmp(z, "%fossil", 7)==0 ){ |
| 812 | 831 | fossil_print("%s", g.argv[0]); |
| 813 | 832 | z += 7; |
| | @@ -829,20 +848,20 @@ |
| 829 | 848 | if( zCmd==0 ) zCmd = P("name"); |
| 830 | 849 | style_header("Command-line Help"); |
| 831 | 850 | if( zCmd ){ |
| 832 | 851 | int rc, idx; |
| 833 | 852 | char *z, *s, *d; |
| 834 | | - |
| 853 | + char const * zCmdOrPage = ('/'==*zCmd) ? "page" : "command"; |
| 835 | 854 | style_submenu_element("Command-List", "Command-List", "%s/help", g.zTop); |
| 836 | | - @ <h1>The "%s(zCmd)" command:</h1> |
| 855 | + @ <h1>The "%s(zCmd)" %s(zCmdOrPage):</h1> |
| 837 | 856 | rc = name_search(zCmd, aCommand, count(aCommand), &idx); |
| 838 | 857 | if( rc==1 ){ |
| 839 | 858 | @ unknown command: %s(zCmd) |
| 840 | 859 | }else if( rc==2 ){ |
| 841 | 860 | @ ambiguous command prefix: %s(zCmd) |
| 842 | 861 | }else{ |
| 843 | | - z = (char*)aCmdHelp[idx]; |
| 862 | + z = (char*)aCmdHelp[idx].zText; |
| 844 | 863 | if( z==0 ){ |
| 845 | 864 | @ no help available for the %s(aCommand[idx].zName) command |
| 846 | 865 | }else{ |
| 847 | 866 | z=s=d=mprintf("%s",z); |
| 848 | 867 | while( *s ){ |
| | @@ -864,21 +883,52 @@ |
| 864 | 883 | |
| 865 | 884 | @ <h1>Available commands:</h1> |
| 866 | 885 | @ <table border="0"><tr> |
| 867 | 886 | for(i=j=0; i<count(aCommand); i++){ |
| 868 | 887 | const char *z = aCommand[i].zName; |
| 869 | | - if( strncmp(z,"test",4)==0 ) continue; |
| 888 | + if( '/'==*z || strncmp(z,"test",4)==0 ) continue; |
| 870 | 889 | j++; |
| 871 | 890 | } |
| 872 | 891 | n = (j+6)/7; |
| 873 | 892 | for(i=j=0; i<count(aCommand); i++){ |
| 874 | 893 | const char *z = aCommand[i].zName; |
| 875 | | - if( strncmp(z,"test",4)==0 ) continue; |
| 894 | + if( '/'==*z || strncmp(z,"test",4)==0 ) continue; |
| 895 | + if( j==0 ){ |
| 896 | + @ <td valign="top"><ul> |
| 897 | + } |
| 898 | + @ <li><a href="%s(g.zTop)/help?cmd=%s(z)">%s(z)</a></li> |
| 899 | + j++; |
| 900 | + if( j>=n ){ |
| 901 | + @ </ul></td> |
| 902 | + j = 0; |
| 903 | + } |
| 904 | + } |
| 905 | + if( j>0 ){ |
| 906 | + @ </ul></td> |
| 907 | + } |
| 908 | + @ </tr></table> |
| 909 | + |
| 910 | + @ <h1>Available pages:</h1> |
| 911 | + @ (Only pages with help text are linked.) |
| 912 | + @ <table border="0"><tr> |
| 913 | + for(i=j=0; i<count(aCommand); i++){ |
| 914 | + const char *z = aCommand[i].zName; |
| 915 | + if( '/'!=*z ) continue; |
| 916 | + j++; |
| 917 | + } |
| 918 | + n = (j+4)/5; |
| 919 | + for(i=j=0; i<count(aCommand); i++){ |
| 920 | + const char *z = aCommand[i].zName; |
| 921 | + if( '/'!=*z ) continue; |
| 876 | 922 | if( j==0 ){ |
| 877 | 923 | @ <td valign="top"><ul> |
| 878 | 924 | } |
| 879 | | - @ <li><a href="%s(g.zTop)/help?cmd=%s(z)">%s(z)</a> |
| 925 | + if( aCmdHelp[i].zText && *aCmdHelp[i].zText ){ |
| 926 | + @ <li><a href="%s(g.zTop)/help?cmd=%s(z)">%s(z+1)</a></li> |
| 927 | + }else{ |
| 928 | + @ <li>%s(z+1)</li> |
| 929 | + } |
| 880 | 930 | j++; |
| 881 | 931 | if( j>=n ){ |
| 882 | 932 | @ </ul></td> |
| 883 | 933 | j = 0; |
| 884 | 934 | } |
| | @@ -885,10 +935,11 @@ |
| 885 | 935 | } |
| 886 | 936 | if( j>0 ){ |
| 887 | 937 | @ </ul></td> |
| 888 | 938 | } |
| 889 | 939 | @ </tr></table> |
| 940 | + |
| 890 | 941 | } |
| 891 | 942 | style_footer(); |
| 892 | 943 | } |
| 893 | 944 | |
| 894 | 945 | /* |
| | @@ -901,11 +952,11 @@ |
| 901 | 952 | style_header("Testpage: All Help Text"); |
| 902 | 953 | for(i=0; i<count(aCommand); i++){ |
| 903 | 954 | if( memcmp(aCommand[i].zName, "test", 4)==0 ) continue; |
| 904 | 955 | @ <h2>%s(aCommand[i].zName):</h2> |
| 905 | 956 | @ <blockquote><pre> |
| 906 | | - @ %h(aCmdHelp[i]) |
| 957 | + @ %h(aCmdHelp[i].zText) |
| 907 | 958 | @ </pre></blockquote> |
| 908 | 959 | } |
| 909 | 960 | style_footer(); |
| 910 | 961 | } |
| 911 | 962 | |
| 912 | 963 | |