Cli: fix empty command

This commit is contained in:
DrZlo13 2021-12-01 14:32:52 +10:00
parent e4edd6e944
commit 8d88c07dec
2 changed files with 17 additions and 6 deletions

View File

@ -7,6 +7,10 @@
void cli_help(Cli* cli, mstring_t* args);
const CliItem cli_items[] = {
{
.name = "?",
.callback = cli_help,
},
{
.name = "help",
.callback = cli_help,
@ -18,6 +22,9 @@ size_t cli_items_count = COUNT_OF(cli_items);
void cli_help(Cli* cli, mstring_t* args) {
for(size_t i = 0; i < cli_items_count; i++) {
cli_write_str(cli, cli_items[i].name);
cli_write_eol(cli);
if((i + 1) < cli_items_count) {
cli_write_eol(cli);
}
}
}

View File

@ -88,7 +88,7 @@ static void cli_write_motd(Cli* cli) {
}
static void cli_write_prompt(Cli* cli) {
cli_write_str(cli, ":>");
cli_write_str(cli, ">: ");
}
static const CliItem* cli_search_item(Cli* cli, const mstring_t* command) {
@ -150,10 +150,14 @@ void cli_handle_char(Cli* cli, uint8_t c) {
switch(c) {
case CliSymbolAsciiCR:
cli_write_eol(cli);
cli_handle_enter(cli);
cli_reset(cli);
cli_write_eol(cli);
if(mstring_size(cli->line) == 0) {
cli_write_eol(cli);
} else {
cli_write_eol(cli);
cli_handle_enter(cli);
cli_reset(cli);
cli_write_eol(cli);
}
cli_write_prompt(cli);
break;
case CliSymbolAsciiDel: