O comando "help" ou "ajuda" sem parâmetros mostram a lista de comandos
acompanhados de uma descrição curta.
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