iocsh: Add underline separator between help outputs

Also tweaks the overall format of the message a bit.
Add tests for new help output format
This commit is contained in:
AlexWells
2023-03-08 15:56:01 +00:00
committed by Michael Davidsaver
parent badd8f518d
commit 6dec68554c
6 changed files with 147 additions and 12 deletions
+9 -7
View File
@@ -285,14 +285,16 @@ LIBCOM_API void errSymLookup(long status, char *pBuf, size_t bufLength);
#define ANSI_ESC_MAGENTA "\033[35;1m"
#define ANSI_ESC_CYAN "\033[36;1m"
#define ANSI_ESC_BOLD "\033[1m"
#define ANSI_ESC_UNDERLINE "\033[4m"
#define ANSI_ESC_RESET "\033[0m"
#define ANSI_RED(STR) ANSI_ESC_RED STR ANSI_ESC_RESET
#define ANSI_GREEN(STR) ANSI_ESC_GREEN STR ANSI_ESC_RESET
#define ANSI_YELLOW(STR) ANSI_ESC_YELLOW STR ANSI_ESC_RESET
#define ANSI_BLUE(STR) ANSI_ESC_BLUE STR ANSI_ESC_RESET
#define ANSI_MAGENTA(STR) ANSI_ESC_MAGENTA STR ANSI_ESC_RESET
#define ANSI_CYAN(STR) ANSI_ESC_CYAN STR ANSI_ESC_RESET
#define ANSI_BOLD(STR) ANSI_ESC_BOLD STR ANSI_ESC_RESET
#define ANSI_RED(STR) ANSI_ESC_RED STR ANSI_ESC_RESET
#define ANSI_GREEN(STR) ANSI_ESC_GREEN STR ANSI_ESC_RESET
#define ANSI_YELLOW(STR) ANSI_ESC_YELLOW STR ANSI_ESC_RESET
#define ANSI_BLUE(STR) ANSI_ESC_BLUE STR ANSI_ESC_RESET
#define ANSI_MAGENTA(STR) ANSI_ESC_MAGENTA STR ANSI_ESC_RESET
#define ANSI_CYAN(STR) ANSI_ESC_CYAN STR ANSI_ESC_RESET
#define ANSI_BOLD(STR) ANSI_ESC_BOLD STR ANSI_ESC_RESET
#define ANSI_UNDERLINE(STR) ANSI_ESC_UNDERLINE STR ANSI_ESC_RESET
#define ERL_ERROR ANSI_RED("ERROR")
#define ERL_WARNING ANSI_MAGENTA("WARNING")
/** @} */
+11 -4
View File
@@ -888,15 +888,19 @@ static void helpCallFunc(const iocshArgBuf *args)
"Type 'help <command>' to see the arguments of <command>. eg. 'help db*'\n");
}
else {
bool firstFunction = true;
for (int iarg = 1 ; iarg < argc ; iarg++) {
for (pcmd = iocshCommandHead ; pcmd != NULL ; pcmd = pcmd->next) {
piocshFuncDef = pcmd->def.pFuncDef;
if (epicsStrGlobMatch(piocshFuncDef->name, argv[iarg]) != 0) {
if(piocshFuncDef->usage) {
fputs("\nUsage: ", epicsGetStdout());
if (! firstFunction) {
fprintf(epicsGetStdout(),
ANSI_UNDERLINE(" \n"));
}
fprintf(epicsGetStdout(),
ANSI_BOLD("%s"),
ANSI_BOLD("\n%s"),
piocshFuncDef->name);
for (int a = 0 ; a < piocshFuncDef->nargs ; a++) {
@@ -909,11 +913,14 @@ static void helpCallFunc(const iocshArgBuf *args)
fprintf(epicsGetStdout(), " '%s'", cp);
}
}
fprintf(epicsGetStdout(),"\n");;
fprintf(epicsGetStdout(),"\n");
if(piocshFuncDef->usage) {
fprintf(epicsGetStdout(), "\n%s", piocshFuncDef->usage);
}
firstFunction = false;
}
}
}
}