Tab completion for commands

Change-Id: Ia38120da7b45cb75effcb2c93eee148419c2fa09
diff --git a/src/ast_handlers.hpp b/src/ast_handlers.hpp
index 5a55f36..f0bbf4c 100644
--- a/src/ast_handlers.hpp
+++ b/src/ast_handlers.hpp
@@ -8,6 +8,8 @@
 
 #pragma once
 
+#include <boost/mpl/for_each.hpp>
+#include "ast_commands.hpp"
 #include "parser_context.hpp"
 #include "schema.hpp"
 #include "utils.hpp"
@@ -534,3 +536,25 @@
         }
     }
 };
+
+struct commandNamesVisitor {
+    template <typename T>
+    auto operator()(boost::type<T>)
+    {
+        return T::name;
+    }
+};
+
+struct createCommandSuggestions_class {
+    template <typename T, typename Iterator, typename Context>
+    void on_success(Iterator const& begin, Iterator const&, T&, Context const& context)
+    {
+        auto& parserContext = x3::get<parser_context_tag>(context);
+        parserContext.m_completionIterator = begin;
+
+        parserContext.m_suggestions.clear();
+        boost::mpl::for_each<CommandTypes, boost::type<boost::mpl::_>>([&parserContext](auto cmd) {
+            parserContext.m_suggestions.emplace(commandNamesVisitor()(cmd));
+        });
+    }
+};