49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
|
|
#include "codegen.h"
|
||
|
|
#include <stdio.h>
|
||
|
|
#include <string>
|
||
|
|
#include <vector>
|
||
|
|
|
||
|
|
static void
|
||
|
|
PrintHelp(const char *program)
|
||
|
|
{
|
||
|
|
printf("\n");
|
||
|
|
printf("PhxRPC ProtoBuf CodeGenerator\n");
|
||
|
|
printf("\n");
|
||
|
|
printf("Subcommand:\n");
|
||
|
|
printf(" client:\n");
|
||
|
|
printf(" server:\n");
|
||
|
|
printf(" service:\n");
|
||
|
|
printf(" tool:\n");
|
||
|
|
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
int
|
||
|
|
main(int argc, char **argv)
|
||
|
|
{
|
||
|
|
if (argc == 1) {
|
||
|
|
PrintHelp(argv[0]);
|
||
|
|
} else {
|
||
|
|
std::vector<char *> args;
|
||
|
|
for (int i = 0; i < argc; i++) {
|
||
|
|
if (i == 1) {// skip subcommmand
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
args.push_back(argv[i]);
|
||
|
|
}
|
||
|
|
std::string subcommand = argv[1];
|
||
|
|
if (subcommand == "client") {
|
||
|
|
client_main(argc - 1, args.data());
|
||
|
|
} else if (subcommand == "server") {
|
||
|
|
server_main(argc - 1, args.data());
|
||
|
|
} else if (subcommand == "service") {
|
||
|
|
service_main(argc - 1, args.data());
|
||
|
|
} else if (subcommand == "tool") {
|
||
|
|
tool_main(argc - 1, args.data());
|
||
|
|
} else {
|
||
|
|
PrintHelp(argv[0]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return 0;
|
||
|
|
}
|