From e83ba7317a4192fb3f253c240dc2922e6a7b5c32 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Wed, 20 Jul 2016 16:32:34 -0400 Subject: [PATCH] 2016-07-20 Fred Gleason * Added a 'help' command to rdclilogedit(1) in 'utils/rdclilogedit/rdclilogedit.cpp'. --- ChangeLog | 3 ++ utils/rdclilogedit/rdclilogedit.cpp | 78 +++++++++++++++++++++++++++++ utils/rdclilogedit/rdclilogedit.h | 1 + 3 files changed, 82 insertions(+) diff --git a/ChangeLog b/ChangeLog index d8f8b50f..4617f201 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15304,3 +15304,6 @@ * Incremented the package version to 2.14.1int01. 2016-07-20 Fred Gleason * Stubbed out a command-line log editor in 'utils/rdclilogedit/'. +2016-07-20 Fred Gleason + * Added a 'help' command to rdclilogedit(1) in + 'utils/rdclilogedit/rdclilogedit.cpp'. diff --git a/utils/rdclilogedit/rdclilogedit.cpp b/utils/rdclilogedit/rdclilogedit.cpp index bc6747e5..a1dd4655 100644 --- a/utils/rdclilogedit/rdclilogedit.cpp +++ b/utils/rdclilogedit/rdclilogedit.cpp @@ -134,6 +134,79 @@ void MainObject::inputActivatedData(int sock) } +void MainObject::Help(const QStringList &cmds) const +{ + bool processed=false; + + if(cmds.size()==1) { + printf("\n"); + printf("The following commands are available:\n"); + printf("?, bye, exit, help, list, listlogs, load, quit, unload\n"); + printf("\n"); + printf("Enter \"? \" for specific help.\n"); + printf("\n"); + processed=true; + } + else { + QString verb=cmds[1].lower(); + if((verb=="bye")||(verb=="exit")||(verb=="quit")) { + printf("\n"); + printf(" %s\n",(const char *)cmds[1]); + printf("\n"); + printf("Exit the program.\n"); + printf("\n"); + processed=true; + } + if((verb=="?")||(verb=="help")) { + printf("\n"); + printf(" %s \n",(const char *)cmds[1]); + printf("\n"); + printf("Print help about command \n"); + printf("\n"); + processed=true; + } + if(verb=="listlogs") { + printf("\n"); + printf(" listlogs\n"); + printf("\n"); + printf("Print the list of Rivendell logs.\n"); + printf("\n"); + processed=true; + } + if(verb=="load") { + printf("\n"); + printf(" load \n"); + printf("\n"); + printf("Load the log into the edit buffer.\n"); + printf("\n"); + processed=true; + } + if(verb=="unload") { + printf("\n"); + printf(" unload\n"); + printf("\n"); + printf("Unload and clear the contents of the edit buffer.\n"); + printf("\n"); + processed=true; + } + if(verb=="list") { + printf("\n"); + printf(" list\n"); + printf("\n"); + printf("Print the contents of the edit buffer.\n"); + printf("\n"); + processed=true; + } + } + + if(!processed) { + printf("\n"); + printf("help: no such command\n"); + printf("\n"); + } +} + + void MainObject::ListLogs() const { QString sql; @@ -207,6 +280,11 @@ void MainObject::DispatchCommand(const QString &cmd) exit(0); } + if((verb=="help")||(verb=="?")) { + Help(cmds); + processed=true; + } + if(verb=="listlogs") { ListLogs(); processed=true; diff --git a/utils/rdclilogedit/rdclilogedit.h b/utils/rdclilogedit/rdclilogedit.h index f901cd6a..cf063e04 100644 --- a/utils/rdclilogedit/rdclilogedit.h +++ b/utils/rdclilogedit/rdclilogedit.h @@ -45,6 +45,7 @@ class MainObject : public QObject void inputActivatedData(int sock); private: + void Help(const QStringList &cmds) const; void ListLogs() const; void Load(const QString &logname); void List();