modify drogon_ctl help command
This commit is contained in:
parent
696a2d016f
commit
beb7ae2b5d
|
@ -24,5 +24,6 @@ public:
|
|||
virtual void handleCommand(std::vector<std::string> ¶meters)=0;
|
||||
virtual bool isTopCommand(){return false;}
|
||||
virtual std::string script(){return "";}
|
||||
virtual std::string detail(){return "";}
|
||||
virtual ~CommandHandler(){}
|
||||
};
|
|
@ -19,7 +19,16 @@
|
|||
#include <iostream>
|
||||
#include <memory>
|
||||
using namespace drogon_ctl;
|
||||
|
||||
std::string create::detail()
|
||||
{
|
||||
return "Use create command to create some source files of drogon webapp\n"
|
||||
"Usage:drogon_ctl create <view|controller> [-options] <object name>\n"
|
||||
"drogon_ctl create view <csp file name> //create HttpView source files from csp file\n"
|
||||
"drogon_ctl create controller [-s] [-n <namespace>] <class_name> //"
|
||||
"create HttpSimpleController source files\n"
|
||||
"drogon_ctl create controller -a <[namespace::]class_name> //"
|
||||
"create HttpApiController source files\n";
|
||||
}
|
||||
|
||||
void create::handleCommand(std::vector<std::string> ¶meters)
|
||||
{
|
||||
|
|
|
@ -25,5 +25,6 @@ namespace drogon_ctl
|
|||
virtual void handleCommand(std::vector<std::string> ¶meters) override;
|
||||
virtual std::string script() override {return "create controller or view class files";}
|
||||
virtual bool isTopCommand() override {return true;}
|
||||
virtual std::string detail() override;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@ namespace drogon_ctl
|
|||
{
|
||||
public:
|
||||
virtual void handleCommand(std::vector<std::string> ¶meters) override;
|
||||
std::string script(){return "create controller files";}
|
||||
|
||||
virtual std::string script() override {return "create controller files";}
|
||||
protected:
|
||||
enum ControllerType{
|
||||
Simple=0,
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
using namespace drogon_ctl;
|
||||
void help::handleCommand(std::vector<std::string> ¶meters)
|
||||
{
|
||||
if(parameters.size()==0)
|
||||
{
|
||||
std::cout<<"usage: drogon_ctl <command> [<args>]"<<std::endl;
|
||||
std::cout<<"commands list:"<<std::endl;
|
||||
for(auto className:drogon::DrClassMap::getAllClassName())
|
||||
|
@ -42,4 +44,22 @@ void help::handleCommand(std::vector<std::string> ¶meters)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto cmd=std::string("drogon_ctl::")+parameters[0];
|
||||
|
||||
auto classPtr=std::shared_ptr<DrObjectBase>(drogon::DrClassMap::newObject(cmd));
|
||||
if(classPtr)
|
||||
{
|
||||
auto cmdHdlPtr=std::dynamic_pointer_cast<CommandHandler>(classPtr);
|
||||
if(cmdHdlPtr)
|
||||
{
|
||||
if(cmdHdlPtr->isTopCommand())
|
||||
std::cout<<cmdHdlPtr->detail()<<std::endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue