X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=lib%2Fhelp.c;h=3a012b4a659c133b3674e23cefc1cd840f4adf73;hb=9deafbf270706a8c3710e45000d02119e38f4001;hp=66573ba2ee05cd775f6f340f57bfdf9ecd29b2b8;hpb=5ca22420e457a92589ea762e9ee77de4ec5d100a;p=cascardo%2Fdeclara.git diff --git a/lib/help.c b/lib/help.c index 66573ba..3a012b4 100644 --- a/lib/help.c +++ b/lib/help.c @@ -26,7 +26,25 @@ #include "cmd.h" #include "util.h" -static const char *helpdir = "help"; +#ifndef DOCDIR +#define DOCDIR "help" +#endif + +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) { @@ -34,7 +52,7 @@ static int run_help(struct declaracao *dec, char **args, int argc) char *filename; char *basename; if (argc == 1) - basename = "help"; + return help_cmds(dec); else if (argc == 2) basename = args[1]; else