mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-09-04 14:48:41 +02:00
2016-07-20 Fred Gleason <fredg@paravelsystems.com>
* Added a 'setcart' command to rdclilogedit(1) in 'utils/rdclilogedit/rdclilogedit.cpp' and 'utils/rdclilogedit/rdclilogedit.h'.
This commit is contained in:
parent
e83ba7317a
commit
60ce6c966d
@ -15307,3 +15307,7 @@
|
||||
2016-07-20 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added a 'help' command to rdclilogedit(1) in
|
||||
'utils/rdclilogedit/rdclilogedit.cpp'.
|
||||
2016-07-20 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added a 'setcart' command to rdclilogedit(1) in
|
||||
'utils/rdclilogedit/rdclilogedit.cpp' and
|
||||
'utils/rdclilogedit/rdclilogedit.h'.
|
||||
|
@ -29,7 +29,8 @@ moc_%.cpp: %.h
|
||||
|
||||
bin_PROGRAMS = rdclilogedit
|
||||
|
||||
dist_rdclilogedit_SOURCES = rdclilogedit.cpp rdclilogedit.h
|
||||
dist_rdclilogedit_SOURCES = help.cpp\
|
||||
rdclilogedit.cpp rdclilogedit.h
|
||||
|
||||
nodist_rdclilogedit_SOURCES = moc_rdclilogedit.cpp
|
||||
|
||||
|
101
utils/rdclilogedit/help.cpp
Normal file
101
utils/rdclilogedit/help.cpp
Normal file
@ -0,0 +1,101 @@
|
||||
// help.cpp
|
||||
//
|
||||
// A command-line log editor for Rivendell
|
||||
//
|
||||
// (C) Copyright 2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include "rdclilogedit.h"
|
||||
|
||||
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 \"? <cmd-name>\" 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 <cmd-name>\n",(const char *)cmds[1]);
|
||||
printf("\n");
|
||||
printf("Print help about command <cmd-name>\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 <log-name>\n");
|
||||
printf("\n");
|
||||
printf("Load the <log-name> log into the edit buffer.\n");
|
||||
printf("\n");
|
||||
processed=true;
|
||||
}
|
||||
if(verb=="setcart") {
|
||||
printf("\n");
|
||||
printf(" setcart <line> <cart-num>\n");
|
||||
printf("\n");
|
||||
printf("Set the cart event at line <line> to use cart <cart-num>.\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");
|
||||
}
|
||||
}
|
@ -134,76 +134,8 @@ void MainObject::inputActivatedData(int sock)
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Help(const QStringList &cmds) const
|
||||
void MainObject::Addcart(int line,unsigned cartnum)
|
||||
{
|
||||
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 \"? <cmd-name>\" 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 <cmd-name>\n",(const char *)cmds[1]);
|
||||
printf("\n");
|
||||
printf("Print help about command <cmd-name>\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 <log-name>\n");
|
||||
printf("\n");
|
||||
printf("Load the <log-name> 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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -247,7 +179,7 @@ void MainObject::Load(const QString &logname)
|
||||
void MainObject::List()
|
||||
{
|
||||
if(edit_log_event==NULL) {
|
||||
fprintf(stderr,"no log loaded\n");
|
||||
fprintf(stderr,"list: no log loaded\n");
|
||||
return;
|
||||
}
|
||||
for(int i=0;i<edit_log_event->size();i++) {
|
||||
@ -257,6 +189,29 @@ void MainObject::List()
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Setcart(int line,unsigned cartnum)
|
||||
{
|
||||
if(edit_log_event==NULL) {
|
||||
fprintf(stderr,"setcart: no log loaded\n");
|
||||
return;
|
||||
}
|
||||
RDLogLine *logline=edit_log_event->logLine(line);
|
||||
if(logline!=NULL) {
|
||||
if((logline->type()==RDLogLine::Cart)||
|
||||
(logline->type()==RDLogLine::Macro)) {
|
||||
logline->setCartNumber(cartnum);
|
||||
edit_log_event->refresh(line);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"setcart: incompatible event type\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"setcart: no such line\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Unload()
|
||||
{
|
||||
if(edit_log!=NULL) {
|
||||
@ -275,6 +230,30 @@ void MainObject::DispatchCommand(const QString &cmd)
|
||||
QStringList cmds=cmds.split(" ",cmd);
|
||||
QString verb=cmds[0].lower();
|
||||
bool processed=false;
|
||||
int line;
|
||||
bool ok=false;
|
||||
|
||||
if(verb=="setcart") {
|
||||
if(cmds.size()==3) {
|
||||
line=cmds[1].toInt(&ok);
|
||||
if(ok&&(line>=0)) {
|
||||
unsigned cartnum=cmds[2].toUInt(&ok);
|
||||
if(ok&&(cartnum<=RD_MAX_CART_NUMBER)) {
|
||||
Setcart(line,cartnum);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"addcart: invalid cart number\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"addcart: invalid line number\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"addcart: invalid command arguments\n");
|
||||
}
|
||||
processed=true;
|
||||
}
|
||||
|
||||
if((verb=="exit")||(verb=="quit")||(verb=="bye")) {
|
||||
exit(0);
|
||||
@ -300,7 +279,7 @@ void MainObject::DispatchCommand(const QString &cmd)
|
||||
Load(cmds[1]);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"invalid command arguments\n");
|
||||
fprintf(stderr,"load: invalid command arguments\n");
|
||||
}
|
||||
processed=true;
|
||||
}
|
||||
|
@ -45,10 +45,12 @@ class MainObject : public QObject
|
||||
void inputActivatedData(int sock);
|
||||
|
||||
private:
|
||||
void Addcart(int line,unsigned cartnum);
|
||||
void Help(const QStringList &cmds) const;
|
||||
void ListLogs() const;
|
||||
void Load(const QString &logname);
|
||||
void List();
|
||||
void Setcart(int line,unsigned cartnum);
|
||||
void Unload();
|
||||
void DispatchCommand(const QString &cmd);
|
||||
QString ListLine(RDLogEvent *evt,int line) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user