From 6b639ff6fc2a7d2d6cbf761474c9cf36afec2721 Mon Sep 17 00:00:00 2001 From: okhsunrog Date: Fri, 23 Feb 2024 12:31:19 +0300 Subject: [PATCH] clrhistory commmand --- main/cmd_utils.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/main/cmd_utils.c b/main/cmd_utils.c index 1aa0634..185341c 100644 --- a/main/cmd_utils.c +++ b/main/cmd_utils.c @@ -7,11 +7,17 @@ #include "xvprintf.h" #include #include +#include "linenoise/linenoise.h" +#include "fs.h" + + static void register_timestamp(void); +static void regiter_clrhistory(void); void register_utils_commands(void) { register_timestamp(); + regiter_clrhistory(); } static struct { @@ -49,3 +55,20 @@ static void register_timestamp(void) { }; ESP_ERROR_CHECK(esp_console_cmd_register(&cmd)); } + +static int clrhistory(int argc, char **argv) { + linenoiseHistoryFree(); + linenoiseHistoryLoad(HISTORY_PATH); + return 0; +} + +static void regiter_clrhistory(void) { + const esp_console_cmd_t cmd = { + .command = "clrhistory", + .help = "Clear command history", + .hint = NULL, + .func = &clrhistory, + }; + ESP_ERROR_CHECK(esp_console_cmd_register(&cmd)); +} +