summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Seigo <aseigo@kde.org>2015-12-25 21:15:47 +0100
committerAaron Seigo <aseigo@kde.org>2015-12-25 21:15:47 +0100
commit26db899f5a12d5ba960e778ce904e279e97481d8 (patch)
tree81b6391cb38ccb17bc01acd797740828df36ad4e
parent47f175743ada27a031c9496a2bd1890c74464b27 (diff)
downloadsink-26db899f5a12d5ba960e778ce904e279e97481d8.tar.gz
sink-26db899f5a12d5ba960e778ce904e279e97481d8.zip
a little welcome banner
-rw-r--r--akonadish/repl/repl.cpp13
-rw-r--r--akonadish/repl/repl.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/akonadish/repl/repl.cpp b/akonadish/repl/repl.cpp
index 395661e..499a4af 100644
--- a/akonadish/repl/repl.cpp
+++ b/akonadish/repl/repl.cpp
@@ -25,8 +25,10 @@
25#include <QFile> 25#include <QFile>
26#include <QFinalState> 26#include <QFinalState>
27#include <QStandardPaths> 27#include <QStandardPaths>
28#include <QTextStream>
28 29
29#include "replStates.h" 30#include "replStates.h"
31#include "syntaxtree.h"
30 32
31Repl::Repl(QObject *parent) 33Repl::Repl(QObject *parent)
32 : QStateMachine(parent) 34 : QStateMachine(parent)
@@ -56,6 +58,7 @@ Repl::Repl(QObject *parent)
56 print->addTransition(print, SIGNAL(completed()), eval); 58 print->addTransition(print, SIGNAL(completed()), eval);
57 59
58 setInitialState(read); 60 setInitialState(read);
61 printWelcomeBanner();
59 start(); 62 start();
60} 63}
61 64
@@ -65,13 +68,23 @@ Repl::~Repl()
65 write_history(commandHistoryPath().toLocal8Bit()); 68 write_history(commandHistoryPath().toLocal8Bit());
66} 69}
67 70
71void Repl::printWelcomeBanner()
72{
73 QTextStream out(stdout);
74 out << QObject::tr("Welcome to the Akonadi2 interative shell!\n");
75 out << QObject::tr("Type `help` for information on the available commands.\n");
76 out.flush();
77}
78
68QString Repl::commandHistoryPath() 79QString Repl::commandHistoryPath()
69{ 80{
70 const QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation); 81 const QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
82
71 if (!QFile::exists(path)) { 83 if (!QFile::exists(path)) {
72 QDir dir; 84 QDir dir;
73 dir.mkpath(path); 85 dir.mkpath(path);
74 } 86 }
87
75 return path + "/repl_history"; 88 return path + "/repl_history";
76} 89}
77 90
diff --git a/akonadish/repl/repl.h b/akonadish/repl/repl.h
index b76c66b..d8d2533 100644
--- a/akonadish/repl/repl.h
+++ b/akonadish/repl/repl.h
@@ -30,5 +30,6 @@ public:
30 ~Repl(); 30 ~Repl();
31 31
32private: 32private:
33 static void printWelcomeBanner();
33 static QString commandHistoryPath(); 34 static QString commandHistoryPath();
34}; 35};