summaryrefslogtreecommitdiffstats
path: root/akonadi2_cli/module.h
diff options
context:
space:
mode:
Diffstat (limited to 'akonadi2_cli/module.h')
-rw-r--r--akonadi2_cli/module.h41
1 files changed, 25 insertions, 16 deletions
diff --git a/akonadi2_cli/module.h b/akonadi2_cli/module.h
index 4f426b8..d2745d0 100644
--- a/akonadi2_cli/module.h
+++ b/akonadi2_cli/module.h
@@ -29,33 +29,42 @@ class Module
29public: 29public:
30 struct Syntax 30 struct Syntax
31 { 31 {
32 enum Interactivity {
33 NotInteractive = 0,
34 EventDriven
35 };
36
32 Syntax(); 37 Syntax();
33 Syntax(const QString &keyword, std::function<bool(const QStringList &, State &)> lambda = std::function<bool(const QStringList &, State &)>(), const QString &helpText = QString(), bool eventDriven = false); 38 Syntax(const QString &keyword,
39 const QString &helpText = QString(),
40 std::function<bool(const QStringList &, State &)> lambda = std::function<bool(const QStringList &, State &)>(),
41 Interactivity interactivity = NotInteractive);
42
34 QString keyword; 43 QString keyword;
35 std::function<bool(const QStringList &, State &)> lambda;
36 QList<Syntax> children;
37 QString help; 44 QString help;
38 bool eventDriven; 45 Interactivity interactivity;
46 std::function<bool(const QStringList &, State &)> lambda;
47
48 QVector<Syntax> children;
39 }; 49 };
40 50
41 typedef std::pair<const Syntax *, QStringList> Command; 51 typedef std::pair<const Syntax *, QStringList> Command;
52 typedef QVector<Module::Syntax> SyntaxList;
42 53
43 static void addModule(const Module &module); 54 static Module *self();
44 static QList<Module> modules();
45 static Command match(const QStringList &commands);
46 static bool run(const QStringList &commands);
47 static void loadModules();
48 static QVector<Syntax>nearestSyntax(const QStringList &words, const QString &fragment);
49 55
50 Module(); 56 SyntaxList syntax() const;
51 Module::Syntax syntax() const; 57 Command match(const QStringList &commands) const;
52 void setSyntax(const Syntax &syntax); 58 SyntaxList nearestSyntax(const QStringList &words, const QString &fragment) const;
59
60 bool run(const QStringList &commands);
53 61
54private: 62private:
63 Module();
55 Command matches(const QStringList &commands) const; 64 Command matches(const QStringList &commands) const;
56 65
57 Syntax m_syntax; 66 SyntaxList m_syntax;
58 static QList<Module> s_modules; 67 State m_state;
59 static State s_state; 68 static Module *s_module;
60}; 69};
61 70