Fossil

Diff
Login

Diff

Differences From Artifact [d701be5728]:

To Artifact [25d9ba1903]:


582
583
584
585
586
587
588




589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615



616
617
618
619
620
621


622






623





























624
625
626
627
628
629
630
631
632



633
634
635
636
637
638
639
640
    fossil_fatal("no help available for the %s command",
       aCommand[idx].zName);
  }
  while( *z ){
    if( *z=='%' && strncmp(z, "%fossil", 7)==0 ){
      printf("%s", g.argv[0]);
      z += 7;




    }else{
      putchar(*z);
      z++;
    }
  }
  putchar('\n');
}

/*
** WEBPAGE: help
** URL: /help?cmd=CMD
*/
void help_page(void){
    const char * zCmd = P("cmd");
    
    style_header("Command line help %s%s",zCmd?" - ":"",zCmd?zCmd:"");
    if( zCmd ){
      int rc, idx;
      char *z, *s, *d;

      @ <h1>%s(zCmd)</h1>
      rc = name_search(zCmd, aCommand, count(aCommand), &idx);
      if( rc==1 ){
        @ unknown command: %s(zCmd)
      }else if( rc==2 ){
        @ ambiguous command prefix: %s(zCmd)
      }else{



        z = (char*)aCmdHelp[idx];
        if( z==0 ){
          @ no help available for the %s(aCommand[idx].zName) command
        }else{
          z=s=d=mprintf("%s",z);
	  while( *s ){


	    if( *s=='%' && strncmp(s, "%fossil", 7)==0 ){






	      s++;





























	    }else{
	      *d++ = *s++;
	    }
	  }
	  *d = 0;
	  @ <pre>%s(z)</pre>
	  free(z);
	}
      }



      @ <hr/><a href="help">available commands</a> in fossil
      @ version %s(MANIFEST_VERSION" "MANIFEST_DATE) UTC
    }else{
      int i;
      
      @ <h1>Available commands</h1>
      for(i=0; i<count(aCommand); i++){
        if( strncmp(aCommand[i].zName,"test",4)==0 ) continue;







>
>
>
>


















<








>
>
>
|
|


<
|
>
>
|
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|


|
|
|


>
>
>
|







582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610

611
612
613
614
615
616
617
618
619
620
621
622
623
624
625

626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
    fossil_fatal("no help available for the %s command",
       aCommand[idx].zName);
  }
  while( *z ){
    if( *z=='%' && strncmp(z, "%fossil", 7)==0 ){
      printf("%s", g.argv[0]);
      z += 7;
    }else if( *z=='<' && strncmp(z,"<a>",3)==0 ){
      z += 3;
    }else if( *z=='<' && strncmp(z,"</a>",4)==0 ){
      z += 4;
    }else{
      putchar(*z);
      z++;
    }
  }
  putchar('\n');
}

/*
** WEBPAGE: help
** URL: /help?cmd=CMD
*/
void help_page(void){
    const char * zCmd = P("cmd");
    
    style_header("Command line help %s%s",zCmd?" - ":"",zCmd?zCmd:"");
    if( zCmd ){
      int rc, idx;


      @ <h1>%s(zCmd)</h1>
      rc = name_search(zCmd, aCommand, count(aCommand), &idx);
      if( rc==1 ){
        @ unknown command: %s(zCmd)
      }else if( rc==2 ){
        @ ambiguous command prefix: %s(zCmd)
      }else{
        char *zSrc, *zDest;
        int src,dest,len;
	
        zSrc = (char*)aCmdHelp[idx];
        if( zSrc==0 || *zSrc==0 ){
          @ no help available for the %s(aCommand[idx].zName) command
        }else{

	  len = strlen(zSrc);
          zDest = malloc(len+1);
	  for(src=dest=0;zSrc[src];){
	    if( zSrc[src]=='%' && strncmp(zSrc+src, "%fossil", 7)==0 ){
	      src++; /* skip % for fossil argv[0] expansion */
	    }else if( zSrc[src]=='<' && strncmp(zSrc+src, "<a>", 3)==0 ){
	      /* found an internal command cross reference,
	      ** create an additional link
	      */
	      int start;

              len+=80;
	      zDest=realloc(zDest,len);
	      zDest[dest++]=zSrc[src++]; /* < */
              zDest[dest++]=zSrc[src++]; /* a */
              zDest[dest++]=' ';
              zDest[dest++]='h';
              zDest[dest++]='r';
              zDest[dest++]='e';
              zDest[dest++]='f';
              zDest[dest++]='=';
              zDest[dest++]='"';
              zDest[dest++]='h';
              zDest[dest++]='e';
              zDest[dest++]='l';
              zDest[dest++]='p';
              zDest[dest++]='?';
              zDest[dest++]='c';
              zDest[dest++]='m';
              zDest[dest++]='d';
              zDest[dest++]='=';
	      start = src+1;
	      for( src=start; zSrc[src] && zSrc[src]!='<'; ){
		zDest[dest++]=zSrc[src++]; /* command name */
	      }
              zDest[dest++]='"';
              zDest[dest++]='>';
	      for( src=start; zSrc[src] && zSrc[src]!='<'; ){
		zDest[dest++]=zSrc[src++]; /* command name */
	      }
	    }else{
	      zDest[dest++] = zSrc[src++];
	    }
	  }
	  zDest[dest] = 0;
	  @ <pre>%s(zDest)</pre>
	  free(zDest);
	}
      }
      @ <hr>additional information may be found in the web documentation:
      @ <a href="doc/tip/www/cmd_%s(aCommand[idx].zName).wiki">
      @ cmd_%s(aCommand[idx].zName)</a>, see also the list of
      @ <a href="help">available commands</a> in fossil
      @ version %s(MANIFEST_VERSION" "MANIFEST_DATE) UTC
    }else{
      int i;
      
      @ <h1>Available commands</h1>
      for(i=0; i<count(aCommand); i++){
        if( strncmp(aCommand[i].zName,"test",4)==0 ) continue;