diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 91e5adb3..b8d4f798 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -8,7 +8,11 @@ project(netopeer2-cli C) # set version set(NP2CLI_VERSION 2.0.78) -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cli_version.h.in" "${PROJECT_BINARY_DIR}/cli_version.h" ESCAPE_QUOTES @ONLY) + +# 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_config.h.in" "${PROJECT_BINARY_DIR}/cli_config.h" ESCAPE_QUOTES @ONLY) include_directories(${PROJECT_BINARY_DIR}) # source files diff --git a/cli/cli_version.h.in b/cli/cli_config.h.in similarity index 81% rename from cli/cli_version.h.in rename to cli/cli_config.h.in index 8e776ed3..3fb2505a 100644 --- a/cli/cli_version.h.in +++ b/cli/cli_config.h.in @@ -4,6 +4,7 @@ * @brief netopeer2-cli version * * @copyright + * Copyright (c) 2024 - Heiko Thiery * Copyright (c) 2019 - 2021 Deutsche Telekom AG. * Copyright (c) 2017 - 2021 CESNET, z.s.p.o. * @@ -15,3 +16,5 @@ */ #define CLI_VERSION "@NP2CLI_VERSION@" + +#define NC_CLI_PROMPT "@CLI_PROMPT@ " diff --git a/cli/commands.h b/cli/commands.h index 42547634..2313633e 100644 --- a/cli/commands.h +++ b/cli/commands.h @@ -17,7 +17,7 @@ #ifndef COMMANDS_H_ #define COMMANDS_H_ -#include "cli_version.h" +#include "cli_config.h" #include @@ -25,8 +25,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. */ diff --git a/cli/main.c b/cli/main.c index c8fa0550..83958e18 100644 --- a/cli/main.c +++ b/cli/main.c @@ -144,7 +144,7 @@ main(void) while (!done) { /* get the command from user */ - cmdline = linenoise(PROMPT); + cmdline = linenoise(NC_CLI_PROMPT); /* EOF -> exit */ if (cmdline == NULL) {