diff options
Diffstat (limited to 'akonadi2_cli/syntax_modules/core_syntax.cpp')
-rw-r--r-- | akonadi2_cli/syntax_modules/core_syntax.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/akonadi2_cli/syntax_modules/core_syntax.cpp b/akonadi2_cli/syntax_modules/core_syntax.cpp index 407fcbf..ca5ac4c 100644 --- a/akonadi2_cli/syntax_modules/core_syntax.cpp +++ b/akonadi2_cli/syntax_modules/core_syntax.cpp | |||
@@ -31,7 +31,10 @@ Syntax::List syntax() | |||
31 | { | 31 | { |
32 | Syntax::List syntax; | 32 | Syntax::List syntax; |
33 | syntax << Syntax("exit", QObject::tr("Exits the application. Ctrl-d also works!"), &CoreSyntax::exit); | 33 | syntax << Syntax("exit", QObject::tr("Exits the application. Ctrl-d also works!"), &CoreSyntax::exit); |
34 | syntax << Syntax(QObject::tr("help"), QObject::tr("Print command information: help [command]"), &CoreSyntax::showHelp); | 34 | |
35 | Syntax help(QObject::tr("help"), QObject::tr("Print command information: help [command]"), &CoreSyntax::showHelp); | ||
36 | help.completer = &CoreSyntax::showHelpCompleter; | ||
37 | syntax << help; | ||
35 | 38 | ||
36 | Syntax set(QObject::tr("set"), QObject::tr("Sets settings for the session")); | 39 | Syntax set(QObject::tr("set"), QObject::tr("Sets settings for the session")); |
37 | set.children << Syntax(QObject::tr("debug"), QObject::tr("Set the debug level from 0 to 6"), &CoreSyntax::setDebugLevel); | 40 | set.children << Syntax(QObject::tr("debug"), QObject::tr("Set the debug level from 0 to 6"), &CoreSyntax::setDebugLevel); |
@@ -92,6 +95,20 @@ bool showHelp(const QStringList &commands, State &state) | |||
92 | return true; | 95 | return true; |
93 | } | 96 | } |
94 | 97 | ||
98 | QStringList showHelpCompleter(const QStringList &commands, const QString &fragment) | ||
99 | { | ||
100 | QStringList items; | ||
101 | |||
102 | for (auto syntax: SyntaxTree::self()->syntax()) { | ||
103 | if (fragment.isEmpty() || syntax.keyword.startsWith(fragment)) { | ||
104 | items << syntax.keyword; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | qSort(items); | ||
109 | return items; | ||
110 | } | ||
111 | |||
95 | bool setDebugLevel(const QStringList &commands, State &state) | 112 | bool setDebugLevel(const QStringList &commands, State &state) |
96 | { | 113 | { |
97 | if (commands.count() != 1) { | 114 | if (commands.count() != 1) { |