diff options
-rw-r--r-- | sinksh/syntax_modules/sink_list.cpp | 6 | ||||
-rw-r--r-- | sinksh/syntaxtree.cpp | 3 | ||||
-rw-r--r-- | sinksh/syntaxtree.h | 11 |
3 files changed, 15 insertions, 5 deletions
diff --git a/sinksh/syntax_modules/sink_list.cpp b/sinksh/syntax_modules/sink_list.cpp index 7421b89..e4c4837 100644 --- a/sinksh/syntax_modules/sink_list.cpp +++ b/sinksh/syntax_modules/sink_list.cpp | |||
@@ -169,14 +169,12 @@ bool list(const QStringList &args_, State &state) | |||
169 | } | 169 | } |
170 | } | 170 | } |
171 | state.flushTable(); | 171 | state.flushTable(); |
172 | state.commandFinished(); | 172 | return true; |
173 | |||
174 | return false; | ||
175 | } | 173 | } |
176 | 174 | ||
177 | Syntax::List syntax() | 175 | Syntax::List syntax() |
178 | { | 176 | { |
179 | Syntax list("list", QObject::tr("List all resources, or the contents of one or more resources."), &SinkList::list, Syntax::EventDriven); | 177 | Syntax list("list", QObject::tr("List all resources, or the contents of one or more resources."), &SinkList::list, Syntax::NotInteractive); |
180 | list.completer = &SinkshUtils::resourceOrTypeCompleter; | 178 | list.completer = &SinkshUtils::resourceOrTypeCompleter; |
181 | return Syntax::List() << list; | 179 | return Syntax::List() << list; |
182 | } | 180 | } |
diff --git a/sinksh/syntaxtree.cpp b/sinksh/syntaxtree.cpp index 65eb769..0eb9782 100644 --- a/sinksh/syntaxtree.cpp +++ b/sinksh/syntaxtree.cpp | |||
@@ -68,6 +68,9 @@ int SyntaxTree::run(const QStringList &commands) | |||
68 | if (success && command.first->interactivity == Syntax::EventDriven) { | 68 | if (success && command.first->interactivity == Syntax::EventDriven) { |
69 | returnCode = m_state.commandStarted(); | 69 | returnCode = m_state.commandStarted(); |
70 | } | 70 | } |
71 | if (!success && command.first->interactivity != Syntax::EventDriven) { | ||
72 | returnCode = 1; | ||
73 | } | ||
71 | } else if (command.first->children.isEmpty()) { | 74 | } else if (command.first->children.isEmpty()) { |
72 | m_state.printError(QObject::tr("Broken command... sorry :("), "st_broken"); | 75 | m_state.printError(QObject::tr("Broken command... sorry :("), "st_broken"); |
73 | } else { | 76 | } else { |
diff --git a/sinksh/syntaxtree.h b/sinksh/syntaxtree.h index 8fbbd01..ce28548 100644 --- a/sinksh/syntaxtree.h +++ b/sinksh/syntaxtree.h | |||
@@ -45,7 +45,16 @@ public: | |||
45 | QString keyword; | 45 | QString keyword; |
46 | QString help; | 46 | QString help; |
47 | Interactivity interactivity; | 47 | Interactivity interactivity; |
48 | std::function<bool(const QStringList &, State &)> lambda; | 48 | |
49 | /** | ||
50 | * This function will be called to execute the command. | ||
51 | * | ||
52 | * @arguments: The command arguments | ||
53 | * @state: The state object | ||
54 | * @return: Return true for success and false for error. If the command is event driven, returning false will not start an event loop and abort immediately. | ||
55 | * If the command is not event driven, returning false will set the exit code to 1. | ||
56 | */ | ||
57 | std::function<bool(const QStringList &arguments, State &state)> lambda; | ||
49 | std::function<QStringList(const QStringList &, const QString &, State &state)> completer; | 58 | std::function<QStringList(const QStringList &, const QString &, State &state)> completer; |
50 | 59 | ||
51 | QVector<Syntax> children; | 60 | QVector<Syntax> children; |