diff --git a/CMakeLists.txt b/CMakeLists.txt
index b0684dd..9d4b860 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,6 +52,7 @@ add_subdirectory(src/pq)
add_subdirectory(src/main)
add_subdirectory(src/common)
add_subdirectory(src/delete)
+add_subdirectory(src/query)
target_link_libraries(${PROJECT_NAME}
INTERFACE ${PostgreSQL_LIBRARIES}
diff --git a/src/query/CMakeLists.txt b/src/query/CMakeLists.txt
new file mode 100644
index 0000000..9ea78d9
--- /dev/null
+++ b/src/query/CMakeLists.txt
@@ -0,0 +1,20 @@
+project(${bare_name}-query CXX)
+
+add_executable(${PROJECT_NAME}
+ main.cpp
+ commandline.cpp
+)
+
+target_include_directories(${PROJECT_NAME}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..
+)
+
+target_link_libraries(${PROJECT_NAME}
+ PRIVATE ${bare_name}-if
+ PRIVATE ${bare_name}-common
+)
+
+string(REPLACE "${bare_name}-" "" ACTION_NAME "${PROJECT_NAME}")
+target_compile_definitions(${PROJECT_NAME}
+ PRIVATE ACTION_NAME="${ACTION_NAME}"
+)
diff --git a/src/query/commandline.cpp b/src/query/commandline.cpp
new file mode 100644
index 0000000..ee59b88
--- /dev/null
+++ b/src/query/commandline.cpp
@@ -0,0 +1,60 @@
+/* Copyright 2015, Michele Santullo
+ * This file is part of "dindexer".
+ *
+ * "dindexer" is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * "dindexer" is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with "dindexer". If not, see .
+ */
+
+#include "commandline.hpp"
+#include "dindexer-common/commandline.hpp"
+#include
+#include
+#include
+
+namespace po = boost::program_options;
+
+namespace din {
+ bool parse_commandline (int parArgc, char* parArgv[], po::variables_map& parVarMap) {
+ po::options_description set_options(ACTION_NAME " options");
+ //set_options.add_options()
+ //("switch,s", "Help message")
+ //("option,o", po::value()->default_value("default_value"), "Help message")
+ //("option2", po::value(), "Help message")
+ //;
+
+ po::options_description positional_options("Positional options");
+ positional_options.add_options()
+ ("query-command", po::value>(), "Query command")
+ ;
+
+ const auto desc = dinlib::get_default_commandline();
+ po::options_description all("Available options");
+ po::positional_options_description pd;
+ all.add(desc).add(positional_options).add(set_options);
+ pd.add("query-command", -1);//.add("pos_option2", 1);
+ try {
+ po::store(po::command_line_parser(parArgc, parArgv).options(all).positional(pd).run(), parVarMap);
+ }
+ catch (const po::validation_error& err) {
+ throw dinlib::ValidationError(err);
+ }
+
+ po::notify(parVarMap);
+
+ if (dinlib::manage_common_commandline(std::cout, ACTION_NAME, "[options...] ", parVarMap, {std::cref(desc), std::cref(set_options)})) {
+ return true;
+ }
+
+ return false;
+ }
+} //namespace din
diff --git a/src/query/commandline.hpp b/src/query/commandline.hpp
new file mode 100644
index 0000000..e088954
--- /dev/null
+++ b/src/query/commandline.hpp
@@ -0,0 +1,29 @@
+/* Copyright 2015, Michele Santullo
+ * This file is part of "dindexer".
+ *
+ * "dindexer" is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * "dindexer" is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with "dindexer". If not, see .
+ */
+
+#ifndef id259FD7C96B5049ECB50386F25455FBB2
+#define id259FD7C96B5049ECB50386F25455FBB2
+
+#include "dindexer-common/validationerror.hpp"
+#include "dindexer-common/mediatypes.hpp"
+#include
+
+namespace din {
+ bool parse_commandline ( int parArgc, char* parArgv[], boost::program_options::variables_map& parVarMap );
+} //namespace din
+
+#endif
diff --git a/src/query/main.cpp b/src/query/main.cpp
new file mode 100644
index 0000000..4b72834
--- /dev/null
+++ b/src/query/main.cpp
@@ -0,0 +1,48 @@
+/* Copyright 2015, Michele Santullo
+ * This file is part of "dindexer".
+ *
+ * "dindexer" is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * "dindexer" is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with "dindexer". If not, see .
+ */
+
+#include "commandline.hpp"
+#include
+#include
+#include
+#include
+#include
+
+int main (int parArgc, char* parArgv[]) {
+ using boost::program_options::variables_map;
+
+ variables_map vm;
+ try {
+ if (din::parse_commandline(parArgc, parArgv, vm)) {
+ return 0;
+ }
+ }
+ catch (const std::invalid_argument& err) {
+ std::cerr << err.what() << "\nUse --help for help" << std::endl;
+ return 2;
+ }
+
+ if (not vm.count("query-command")) {
+ std::cerr << "No query specified, please use --help for usage instructions\n";
+ return 2;
+ }
+
+ const auto query_command = boost::algorithm::join(vm["query-command"].as>(), " ");
+ std::cout << "Query: " << query_command << '\n';
+ return 0;
+}
+