From b3de8d2155a0b28042e4871a3448248b4cedce99 Mon Sep 17 00:00:00 2001 From: Jeff Palmer Date: Fri, 1 Jun 2018 01:36:01 +0300 Subject: [PATCH] Configurable shell messages This commit adds the possibility to configure various shell messages (and some internal variables) by defining the respective macros at compile time. --- inc/shell.h | 11 +++++++++++ src/shell/shell_ver.c | 25 ++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/inc/shell.h b/inc/shell.h index a787015c..a567d1e3 100644 --- a/inc/shell.h +++ b/inc/shell.h @@ -4,12 +4,23 @@ #define __SHELL_H__ #include "type.h" +#include "platform_conf.h" +#if !defined(SHELL_WELCOMEMSG) #define SHELL_WELCOMEMSG "\neLua %s Copyright (C) 2007-2013 www.eluaproject.net\n" +#endif +#if !defined(SHELL_PROMPT) #define SHELL_PROMPT "eLua# " +#endif +#if !defined(SHELL_ERRMSG) #define SHELL_ERRMSG "Invalid command, type 'help' for help\n" +#endif +#if !defined(SHELL_MAXSIZE) #define SHELL_MAXSIZE 50 +#endif +#if !defined(SHELL_MAX_LUA_ARGS) #define SHELL_MAX_LUA_ARGS 8 +#endif // Shell command handler function typedef void( *p_shell_handler )( int argc, char **argv ); diff --git a/src/shell/shell_ver.c b/src/shell/shell_ver.c index 7af5b20a..b6bf8795 100644 --- a/src/shell/shell_ver.c +++ b/src/shell/shell_ver.c @@ -17,9 +17,24 @@ #include "version.h" #endif -const char shell_help_ver[] = "\n" - "This displays the git revision of the tree used to build eLua or an official version number if applicable.\n"; -const char shell_help_summary_ver[] = "show version information"; +#ifndef SHELL_HELP_VER_STRING +#define SHELL_HELP_VER_STRING "\nThis displays the git revision of the tree used to build eLua or an official version number if applicable.\n" +#endif + +#ifndef SHELL_HELP_SUMMARY_STRING +#define SHELL_HELP_SUMMARY_STRING "show version information" +#endif + +#ifndef SHELL_HELP_LINE1_STRING +#define SHELL_HELP_LINE1_STRING "eLua version %s\n" +#endif + +#ifndef SHELL_HELP_LINE2_STRING +#define SHELL_HELP_LINE2_STRING "For more information visit www.eluaproject.net and wiki.eluaproject.net\n" +#endif + +const char shell_help_ver[] = SHELL_HELP_VER_STRING; +const char shell_help_summary_ver[] = SHELL_HELP_SUMMARY_STRING; void shell_ver( int argc, char **argv ) { @@ -28,7 +43,7 @@ void shell_ver( int argc, char **argv ) SHELL_SHOW_HELP( ver ); return; } - printf( "eLua version %s\n", ELUA_STR_VERSION ); - printf( "For more information visit www.eluaproject.net and wiki.eluaproject.net\n" ); + printf( SHELL_HELP_LINE1_STRING, ELUA_STR_VERSION ); + printf( SHELL_HELP_LINE2_STRING ); }