From d40190f452fa1faf30822b9451f55b8a5dbfdbae Mon Sep 17 00:00:00 2001 From: antao Date: Tue, 4 Sep 2018 14:50:18 +0800 Subject: [PATCH] Add creating project function in drogon_ctl --- drogon_ctl/create.cc | 5 +- drogon_ctl/create_project.cc | 109 +++++++++++++++++++++++++++++++++++ drogon_ctl/create_project.h | 31 ++++++++++ 3 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 drogon_ctl/create_project.cc create mode 100644 drogon_ctl/create_project.h diff --git a/drogon_ctl/create.cc b/drogon_ctl/create.cc index 3bd75b0c..83f930fe 100755 --- a/drogon_ctl/create.cc +++ b/drogon_ctl/create.cc @@ -29,7 +29,10 @@ std::string create::detail() "drogon_ctl create controller -a <[namespace::]class_name> //" "create HttpApiController source files\n" "drogon_ctl create controller -w [-n ] //" - "create WebSocketController source files\n"; + "create WebSocketController source files\n" + "drogon_ctl create project //" + "create a project named project_name\n"; + } void create::handleCommand(std::vector ¶meters) diff --git a/drogon_ctl/create_project.cc b/drogon_ctl/create_project.cc new file mode 100644 index 00000000..a5ac377a --- /dev/null +++ b/drogon_ctl/create_project.cc @@ -0,0 +1,109 @@ +#include "create_project.h" +#include +#include +#include +#include +#include + +using namespace drogon_ctl; + +void create_project::handleCommand(std::vector ¶meters) +{ + if(parameters.size()<1) + { + std::cout<<"please input project name"<\n" + "int main() {\n" + " //设置http监听的地址和端口\n" + " drogon::HttpAppFramework::instance().addListener(\"0.0.0.0\",80);\n" + " //运行http框架,程序阻塞在底层的事件循环中\n" + " drogon::HttpAppFramework::instance().run();\n" + " return 0;\n" + "}"; +} +static void newGitIgFile(std::ofstream &gitFile) +{ + gitFile<<"# Prerequisites\n" + "*.d\n" + "\n" + "# Compiled Object files\n" + "*.slo\n" + "*.lo\n" + "*.o\n" + "*.obj\n" + "\n" + "# Precompiled Headers\n" + "*.gch\n" + "*.pch\n" + "\n" + "# Compiled Dynamic libraries\n" + "*.so\n" + "*.dylib\n" + "*.dll\n" + "\n" + "# Fortran module files\n" + "*.mod\n" + "*.smod\n" + "\n" + "# Compiled Static libraries\n" + "*.lai\n" + "*.la\n" + "*.a\n" + "*.lib\n" + "\n" + "# Executables\n" + "*.exe\n" + "*.out\n" + "*.app\n" + "\n" + "build\n" + "cmake-build-debug\n" + ".idea\n"; +} +void create_project::createProject(const std::string &projectName) +{ + std::cout<<"create a project named "< +#include "CommandHandler.h" +using namespace drogon; +namespace drogon_ctl +{ + class create_project:public DrObject,public CommandHandler + { + public: + virtual void handleCommand(std::vector ¶meters) override; + virtual std::string script() override {return "create a project";} + + protected: + std::string _outputPath="."; + void createProject(const std::string &projectName); + }; +} \ No newline at end of file