summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrank LENORMAND <lenormf@gmail.com>2017-06-17 11:27:07 +0300
committerFrank LENORMAND <lenormf@gmail.com>2017-06-17 11:27:07 +0300
commit8d24768d5d0d2eaa49ed1487b83c4526112d89b2 (patch)
tree623514029c8b78b0523fcc6dfda6ce2c04abbb4a /src
parentf9c48237a7d3a8c2aae44c532a398f62ea0100f1 (diff)
src: Add a `commands` debug flag
This commit allows setting the `commands` flag to the `debug` option, in order to have the engine write on the *debug* buffer the commands that are being executed, along with their arguments.
Diffstat (limited to 'src')
-rw-r--r--src/command_manager.cc11
-rw-r--r--src/option.hh16
2 files changed, 20 insertions, 7 deletions
diff --git a/src/command_manager.cc b/src/command_manager.cc
index 6ab012d1..4d422feb 100644
--- a/src/command_manager.cc
+++ b/src/command_manager.cc
@@ -9,6 +9,7 @@
#include "utils.hh"
#include "optional.hh"
#include "containers.hh"
+#include "buffer_utils.hh"
#include <algorithm>
@@ -443,6 +444,16 @@ void CommandManager::execute_single_command(CommandParameters params,
if (command_it == m_commands.end())
throw command_not_found(params[0]);
+ const DebugFlags debug_flags = context.options()["debug"].get<DebugFlags>();
+ if (debug_flags & DebugFlags::Commands)
+ {
+ String repr_parameters;
+
+ for (auto repr_param : param_view)
+ repr_parameters += " " + repr_param;
+ write_to_debug_buffer(format("command {}{}", params[0], repr_parameters));
+ }
+
try
{
ParametersParser parameter_parser(param_view,
diff --git a/src/option.hh b/src/option.hh
index dc1acaae..c0d450d5 100644
--- a/src/option.hh
+++ b/src/option.hh
@@ -36,22 +36,24 @@ using TimestampedList = PrefixedList<size_t, T>;
enum class DebugFlags
{
- None = 0,
- Hooks = 1 << 0,
- Shell = 1 << 1,
- Profile = 1 << 2,
- Keys = 1 << 3,
+ None = 0,
+ Hooks = 1 << 0,
+ Shell = 1 << 1,
+ Profile = 1 << 2,
+ Keys = 1 << 3,
+ Commands = 1 << 4,
};
constexpr bool with_bit_ops(Meta::Type<DebugFlags>) { return true; }
-constexpr Array<EnumDesc<DebugFlags>, 4> enum_desc(Meta::Type<DebugFlags>)
+constexpr Array<EnumDesc<DebugFlags>, 5> enum_desc(Meta::Type<DebugFlags>)
{
return { {
{ DebugFlags::Hooks, "hooks" },
{ DebugFlags::Shell, "shell" },
{ DebugFlags::Profile, "profile" },
- { DebugFlags::Keys, "keys" }
+ { DebugFlags::Keys, "keys" },
+ { DebugFlags::Commands, "commands" },
} };
}