cmd_help.c 534 B

123456789101112131415161718192021222324252627
  1. #include "cmd_help.h"
  2. #include <libc/stdio.h>
  3. #include <libc/stdlib.h>
  4. struct help_table_item_t
  5. {
  6. void (*func)();
  7. };
  8. struct help_table_item_t help_table[] = {
  9. {shell_help_cd},
  10. };
  11. static const int help_table_num = sizeof(help_table) / sizeof(struct help_table_item_t);
  12. int shell_help(int argc, char **argv)
  13. {
  14. printf("Help:\n");
  15. for (int i = 0; i < help_table_num; ++i)
  16. help_table[i].func();
  17. if(argc > 1)
  18. free(argv);
  19. }
  20. void shell_help_cd()
  21. {
  22. printf("Example of cd: cd [destination]\n");
  23. }