Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Improvements to "help": List commands if the command for which help is requested is unknown. If the command prefix is ambiguous, show all alternatives. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
1b159db28210a14b82f001f8c1f002d1 |
| User & Date: | drh 2011-01-12 02:24:06.238 |
Context
|
2011-01-12
| ||
| 15:53 | Fix for an apparent minor error in allowed markup types for inline text. ... (check-in: dddaebf605 user: lrem tags: trunk) | |
| 02:24 | Improvements to "help": List commands if the command for which help is requested is unknown. If the command prefix is ambiguous, show all alternatives. ... (check-in: 1b159db282 user: drh tags: trunk) | |
| 02:08 | Allow --help anywhere on the command-line as an alternative way to get "help" for a command. ... (check-in: a00888f666 user: drh tags: trunk) | |
Changes
Changes to src/main.c.
| ︙ | ︙ | |||
601 602 603 604 605 606 607 |
zSpacer = " ";
}
printf("\n");
}
}
/*
| | < < < | > > | | < | 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 |
zSpacer = " ";
}
printf("\n");
}
}
/*
** List of commands starting with zPrefix, or all commands if zPrefix is NULL.
*/
static void cmd_cmd_list(const char *zPrefix){
int i, nCmd;
int nPrefix = zPrefix ? strlen(zPrefix) : 0;
const char *aCmd[count(aCommand)];
for(i=nCmd=0; i<count(aCommand); i++){
const char *z = aCommand[i].zName;
if( memcmp(z,"test",4)==0 ) continue;
if( zPrefix && memcmp(zPrefix, z, nPrefix)!=0 ) continue;
aCmd[nCmd++] = aCommand[i].zName;
}
multi_column_list(aCmd, nCmd);
}
/*
** COMMAND: test-commands
**
** Usage: %fossil test-commands
**
** List all commands used for testing and debugging.
*/
void cmd_test_cmd_list(void){
int i, nCmd;
const char *aCmd[count(aCommand)];
for(i=nCmd=0; i<count(aCommand); i++){
if( strncmp(aCommand[i].zName,"test",4)!=0 ) continue;
aCmd[nCmd++] = aCommand[i].zName;
}
multi_column_list(aCmd, nCmd);
}
/*
|
| ︙ | ︙ | |||
658 659 660 661 662 663 664 |
** Usage: %fossil help COMMAND
**
** Display information on how to use COMMAND
*/
void help_cmd(void){
int rc, idx;
const char *z;
| | | | > > | > > > | 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 686 |
** Usage: %fossil help COMMAND
**
** Display information on how to use COMMAND
*/
void help_cmd(void){
int rc, idx;
const char *z;
if( g.argc<3 ){
printf("Usage: %s help COMMAND.\nAvailable COMMANDs:\n",
fossil_nameofexe());
cmd_cmd_list(0);
version_cmd();
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]);
cmd_cmd_list(0);
fossil_exit(1);
}else if( rc==2 ){
fossil_print("ambiguous command prefix: %s\nMatching commands:\n",
g.argv[2]);
cmd_cmd_list(g.argv[2]);
fossil_exit(1);
}
z = aCmdHelp[idx];
if( z==0 ){
fossil_fatal("no help available for the %s command",
aCommand[idx].zName);
}
while( *z ){
|
| ︙ | ︙ |