void shell_loop() { Command cmd; bool end = false; do { vga_terminal_puts("\n >: "); shell_get_command(); //shell_exec_command(cmd); } while (!end); }
int cmd_help (Shell *shell, void *args) { if (array_is_empty (args)) { printf ("Available commands:\n"); const Array *a = shell_get_commands (shell); for (size_t i = 0, n = array_get_size (a); i < n; ++i) { const command_t *command = array_get (a, i); printf (" %s\n", command->name); } return 0; } int return_value = 0; for (size_t i = 0, n = array_get_size (args); i < n; ++i) { const char *name = array_get (args, i); const command_t *p = shell_get_command (shell, name); if (!p) // Command not found. { fprintf (stderr, "No command \"%s\" found.\n", name); --return_value; } else { printf ("- %s: %s", name, name); if (p->args_list) { printf (" %s", p->args_list); } printf ("\n "); if (p->help) { printf ("%s", p->help); } else { printf ("%s", "No help available for this command."); } printf ("\n"); } } return return_value; }