close #30 added overwritable help command parameter and fixed some compiler issues (some of them only appeared when compiling with optimization)

This commit is contained in:
prozessorkern
2020-03-01 17:53:27 +01:00
parent 4f9ff4fe3c
commit c04accdb55
10 changed files with 65 additions and 14 deletions

View File

@@ -260,8 +260,8 @@ shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t handle,
uint8_t cmdExecuted = 0u;
uint32_t cmdLen;
char *tempString;
char *argumentString;
uint32_t argumentLength;
char *argumentString = NULL;
uint32_t argumentLength = 0u;
uint32_t byteCounter;
uint32_t idx;

View File

@@ -327,7 +327,12 @@ static shellmatta_retCode_t helpCmdFct(shellmatta_handle_t handle, const char *a
return ret;
}
shellmatta_cmd_t helpCmd = {(char*)"help", (char*)"h", (char*)"Print this help text", (char*)"help", helpCmdFct, NULL};
shellmatta_cmd_t helpCmd = { SHELLMATTA_HELP_COMMAND
, SHELLMATTA_HELP_ALIAS
, SHELLMATTA_HELP_HELP_TEXT
, SHELLMATTA_HELP_USAGE_TEXT
, helpCmdFct
, NULL};
/**
* @brief terminates an input and prints the prompt again

View File

@@ -22,7 +22,7 @@
#include "shellmatta.h"
#include <stdint.h>
/* some helper macros */
#define SHELLMATTA_MIN(a,b) (((a) > (b)) ? (b) : (a))
#define SHELLMATTA_MAX(a,b) (((a) < (b)) ? (b) : (a))
#define SHELLMATTA_PRINT_BUFFER(buffer,cnt,fct) \
@@ -40,10 +40,38 @@ extern shellmatta_cmd_t helpCmd;
#define SHELLMATTA_MAGIC 0x5101E110u
/*! \brief overwritable output buffer size */
#ifndef SHELLMATTA_OUTPUT_BUFFER_SIZE
#define SHELLMATTA_OUTPUT_BUFFER_SIZE 128u
#endif
/*! @defgroup Shellmatta Help command overwrites
* @{
* overwritable help command parameters - the help command is built in and cannot be removed, but you can change
* the command, alias and help texts by defining them in your build process
* To change the settings set one of these defines:
* #SHELLMATTA_HELP_COMMAND to overwrite the help command
* #SHELLMATTA_HELP_ALIAS to overwrite the help alias
* #SHELLMATTA_HELP_HELP_TEXT to overwrite the help text
* #SHELLMATTA_HELP_USAGE_TEXT to overwrite the usage text
* e.g. use _-DSHELLMATTA_HELP_ALIAS=\"?\"_ as compile option to change the alias to ?
*/
#ifndef SHELLMATTA_HELP_COMMAND
#define SHELLMATTA_HELP_COMMAND (char*)"help" /*!< help command */
#endif
#ifndef SHELLMATTA_HELP_ALIAS
#define SHELLMATTA_HELP_ALIAS (char*)"h" /*!< help command alias */
#endif
#ifndef SHELLMATTA_HELP_HELP_TEXT
#define SHELLMATTA_HELP_HELP_TEXT (char*)"Print this help text" /*!< help command help text */
#endif
#ifndef SHELLMATTA_HELP_USAGE_TEXT
#define SHELLMATTA_HELP_USAGE_TEXT (char*)"help" /*!< help command usage text */
#endif
/*!
* @}
*/
void utils_writeEcho( shellmatta_instance_t *inst,
const char *data,
uint32_t length);