Add help command
Change-Id: Ifbda5a7aafefe396854c00add315fb7a67d4fb26
diff --git a/src/interpreter.cpp b/src/interpreter.cpp
index 80e6195..5d22b6b 100644
--- a/src/interpreter.cpp
+++ b/src/interpreter.cpp
@@ -75,6 +75,32 @@
std::cout << it << std::endl;
}
+struct commandLongHelpVisitor : boost::static_visitor<const char*> {
+ template <typename T>
+ auto constexpr operator()(boost::type<T>) const
+ {
+ return T::longHelp;
+ }
+};
+
+struct commandShortHelpVisitor : boost::static_visitor<const char*> {
+ template <typename T>
+ auto constexpr operator()(boost::type<T>) const
+ {
+ return T::shortHelp;
+ }
+};
+
+void Interpreter::operator()(const help_& help) const
+{
+ if (help.m_cmd)
+ std::cout << boost::apply_visitor(commandLongHelpVisitor(), help.m_cmd.get()) << std::endl;
+ else
+ boost::mpl::for_each<CommandTypes, boost::type<boost::mpl::_>>([](auto cmd) {
+ std::cout << commandShortHelpVisitor()(cmd) << std::endl;
+ });
+}
+
template <typename T>
std::string Interpreter::absolutePathFromCommand(const T& command) const
{