diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 29761043..ce7946fd 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -11,6 +11,10 @@ set(NP2CLI_VERSION 2.0.77) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cli_version.h.in" "${PROJECT_BINARY_DIR}/cli_version.h" ESCAPE_QUOTES @ONLY) include_directories(${PROJECT_BINARY_DIR}) +# configure CLI prompt +set(CLI_PROMPT ">" CACHE STRING "Set the CLI prompt (a space is automatically appended at the end)") +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cli_prompt.h.in" "${PROJECT_BINARY_DIR}/cli_prompt.h" ESCAPE_QUOTES @ONLY) + # source files set(CLI_SRC main.c diff --git a/cli/cli_prompt.h.in b/cli/cli_prompt.h.in new file mode 100644 index 00000000..f7dd143f --- /dev/null +++ b/cli/cli_prompt.h.in @@ -0,0 +1,16 @@ +/** + * @file cli_prompt.h + * @author Heiko Thiery + * @brief netopeer2-cli prompt + * + * @copyright + * Copyright (c) 2024 Heiko Thiery + * + * This source code is licensed under BSD 3-Clause License (the "License"). + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + */ + +#define PROMPT "@CLI_PROMPT@ " diff --git a/cli/commands.h b/cli/commands.h index 42547634..6e86be64 100644 --- a/cli/commands.h +++ b/cli/commands.h @@ -18,6 +18,7 @@ #define COMMANDS_H_ #include "cli_version.h" +#include "cli_prompt.h" #include @@ -25,8 +26,6 @@ extern char some_msg[]; #define INSTRUCTION(format, args ...) {snprintf(some_msg,4095,format,##args);printf("\n %s",some_msg);} #define ERROR(function, format, args ...) {snprintf(some_msg,4095,format,##args);fprintf(stderr,"%s: %s\n",function,some_msg);} -#define PROMPT "> " - typedef struct { char *name; /* User printable name of the function. */