relpipe-in-cli.cpp
branchv_0
changeset 12 bc6fe00dd831
parent 11 3798b6bc9aea
child 13 5e95f0c0a4f9
--- a/relpipe-in-cli.cpp	Sat Jul 28 14:06:53 2018 +0200
+++ b/relpipe-in-cli.cpp	Sat Jul 28 14:16:44 2018 +0200
@@ -11,8 +11,7 @@
 #include "CLI.h"
 #include "Command.h"
 #include "ArgumentsCommand.h"
-
-int demo();
+#include "DemoCommand.h"
 
 int main(int argc, char** argv) {
 	using namespace relpipe::cli;
@@ -34,10 +33,13 @@
 			}
 
 			if (action == L"demo") {
-				resultCode = demo();
+				DemoCommand command;
+				command.process(cin, cout, action, arguments);
+				resultCode = CLI::EXIT_CODE_SUCCESS;
 			} else if (action == L"generate") {
 				ArgumentsCommand command;
 				command.process(cin, cout, action, arguments);
+				resultCode = CLI::EXIT_CODE_SUCCESS;
 			} else {
 				fwprintf(stderr, L"Unknown command: %ls\n", action.c_str());
 				resultCode = CLI::EXIT_CODE_UNKNOWN_COMMAND;
@@ -54,51 +56,5 @@
 		resultCode = CLI::EXIT_CODE_DATA_ERROR;
 	}
 
-
 	return resultCode;
-
 }
-
-int demo() {
-	using namespace relpipe::writer;
-	std::shared_ptr<RelationalWriter> writer(Factory::create(std::cout));
-
-
-	// Various data types passed as strings
-	writer->startRelation(L"table_from_strings",{
-		{L"s", TypeId::STRING},
-		{L"i", TypeId::INTEGER},
-		{L"b", TypeId::BOOLEAN}
-	}, true);
-
-	writer->writeAttribute(L"a");
-	writer->writeAttribute(L"1");
-	writer->writeAttribute(L"true");
-
-	writer->writeAttribute(L"b");
-	writer->writeAttribute(L"2");
-	writer->writeAttribute(L"false");
-
-
-	// Various data types passed as raw pointers + typeids
-	writer->startRelation(L"from_raw_pointers",{
-		{L"s", TypeId::STRING},
-		{L"i", TypeId::INTEGER},
-		{L"b", TypeId::BOOLEAN}
-	}, true);
-
-	string_t sValue;
-	integer_t iValue;
-	boolean_t bValue;
-
-	for (int i = 0; i < 8; i++) {
-		sValue.append(L"*");
-		iValue = i + 1;
-		bValue = iValue % 2 == 0;
-		writer->writeAttribute(&sValue, typeid (sValue));
-		writer->writeAttribute(&iValue, typeid (iValue));
-		writer->writeAttribute(&bValue, typeid (bValue));
-	}
-
-	return 0;
-}