X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=lib%2Fhelp.c;h=0abc112c0ef711c9beee00595b9d86659c77453b;hb=ae234b115f2ad04493e1aef36dbd6b697ef0b68b;hp=39a53e11202a04d6611a8bfeedfde96d959a4a9b;hpb=a788453eccdb7863e837b7795bd559d4aecc9067;p=cascardo%2Fdeclara.git diff --git a/lib/help.c b/lib/help.c index 39a53e1..0abc112 100644 --- a/lib/help.c +++ b/lib/help.c @@ -32,13 +32,27 @@ static const char *helpdir = DOCDIR; +static int help_cmds(struct declaracao *dec) +{ + void *iter = NULL; + struct cmd *cmd; + printf("\n"); + while ((cmd = cmd_next(&iter)) != NULL) { + printf("%s - ", cmd->name); + if (cmd->help) + printf("%s", cmd->help); + printf("\n"); + } + printf("\n"); +} + static int run_help(struct declaracao *dec, char **args, int argc) { int r; char *filename; char *basename; if (argc == 1) - basename = "help"; + return help_cmds(dec); else if (argc == 2) basename = args[1]; else @@ -57,11 +71,13 @@ static int run_help(struct declaracao *dec, char **args, int argc) static struct cmd cmd_help = { .name = "help", .run = run_help, + .help = "mostra ajuda de comandos", }; static struct cmd cmd_ajuda = { .name = "ajuda", .run = run_help, + .help = "mostra ajuda de comandos", }; int help_cmd_init(void)