drogon/drogon_ctl/main.cc

51 lines
888 B
C++
Raw Normal View History

2018-05-31 09:00:31 +00:00
/**
*
2018-12-07 07:50:18 +00:00
* main.cc
* An Tao
2018-05-31 09:00:31 +00:00
*
* Copyright 2018, An Tao. All rights reserved.
2018-12-07 07:50:18 +00:00
* https://github.com/an-tao/drogon
2018-05-31 09:00:31 +00:00
* Use of this source code is governed by a MIT license
* that can be found in the License file.
*
2018-11-16 05:26:14 +00:00
* Drogon
2018-12-07 07:50:18 +00:00
*
2018-05-31 09:00:31 +00:00
*/
#include "cmd.h"
2018-05-28 06:34:47 +00:00
#include <string>
#include <vector>
#include <iostream>
2018-10-14 07:56:54 +00:00
int main(int argc, char *argv[])
2018-05-28 06:34:47 +00:00
{
2018-10-14 07:56:54 +00:00
if (argc < 2)
2018-05-28 06:34:47 +00:00
{
2018-10-14 07:56:54 +00:00
std::vector<std::string> args = {"help"};
2018-05-30 09:44:09 +00:00
exeCommand(args);
2018-05-28 06:34:47 +00:00
return 0;
}
std::vector<std::string> args;
2018-10-14 07:56:54 +00:00
for (int i = 1; i < argc; i++)
2018-05-28 06:34:47 +00:00
{
args.push_back(argv[i]);
2018-05-28 06:34:47 +00:00
}
2019-06-26 09:58:25 +00:00
if (args.size() > 0)
{
2019-06-26 09:58:25 +00:00
auto &arg = args[0];
if (arg == "-h" || arg == "--help")
{
arg = "help";
}
else if (arg == "-v" || arg == "--version")
{
arg = "version";
}
}
exeCommand(args);
2018-05-28 06:34:47 +00:00
return 0;
2018-11-16 05:26:14 +00:00
}