1 Star 0 Fork 4

zhao_jd/CommandLineArguments

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cmdline.cxx 1.37 KB
一键复制 编辑 原始数据 按行查看 历史
江二十三 提交于 2015-03-01 14:36 . get help used by Arguments function
#include <iostream>
#include <CommandLineArguments.hxx>
#include <Encoding.hxx>
int cmdUnknownArgument(const char *args, void *) {
std::cout << "cmd Unknown Options " << args
<< std::endl;
return 1;
}
int main(int argc,char **argv)
{
bool help=false;
std::string driverModel;
std::string profile;
int port;
cmsys::Encoding::CommandLineArguments encoding_cmd=cmsys::Encoding::CommandLineArguments::Main(argc,argv);
int Argc=encoding_cmd.argc();
char const *const* Argv=encoding_cmd.argv();
typedef cmsys::CommandLineArguments argT;
cmsys::CommandLineArguments Args;
Args.Initialize(Argc,Argv);
Args.AddArgument("--help", argT::NO_ARGUMENT, &help,
"Cmd Print Help");
Args.AddArgument("-D", argT::SPACE_ARGUMENT, &driverModel, "Driver Model");
Args.AddArgument("-P", argT::SPACE_ARGUMENT, &port, "Server Lister Ports");
Args.AddArgument("-C", argT::SPACE_ARGUMENT, &profile, "Set Profile");
Args.SetUnknownArgumentCallback(cmdUnknownArgument);
int parsed=Args.Parse();
if(help)
{
std::cout<<"Print Usage:"<<std::endl;
std::cout << Args.GetHelp() << std::endl;
return 0;
}
if(parsed)
{
std::cout << "Parser:" << parsed << std::endl;
std::cout<<"Profile: "<<profile<<"\nDriver Model:"<<driverModel<<"\nPorts:"<<port<<std::endl;
}
return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/zhao_jd/CommandLineArguments.git
git@gitee.com:zhao_jd/CommandLineArguments.git
zhao_jd
CommandLineArguments
CommandLineArguments
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385