Add name paramater to options
This commit is contained in:
parent
426fcf43c4
commit
96d9c1b759
@ -18,10 +18,8 @@ int main(int argc, char** argv){
|
||||
|
||||
setRoutes(app);
|
||||
|
||||
std::cerr << "Setting up app" << std::endl;
|
||||
|
||||
app.port(flags->port)
|
||||
.server_name("proc_api")
|
||||
.server_name(flags->name)
|
||||
.multithreaded();
|
||||
|
||||
delete flags;
|
||||
|
@ -9,7 +9,8 @@
|
||||
void help(char* progName){
|
||||
std::cout << "Usage: " << progName << " [FLAGS]\n";
|
||||
std::cout << "Options:\n";
|
||||
std::cout << " [-p] Port to listen on\n";
|
||||
std::cout << " [-p PORT] Port to listen on (Default 5000)\n";
|
||||
std::cout << " [-n NAME] Server name (Default \"proc-api\")\n";
|
||||
std::cout << " [-h] Display this help message\n\n";
|
||||
exit(1);
|
||||
}
|
||||
@ -20,13 +21,16 @@ option_flags* parse_options(int argc, char** argv){
|
||||
option_flags* ret = new option_flags;
|
||||
|
||||
ret->port = 5000;
|
||||
ret->name = "proc-api";
|
||||
|
||||
while((c = getopt(argc, argv, optarg_string)) != -1){
|
||||
switch(c){
|
||||
case 'p':
|
||||
std::cout << optarg << "\n";
|
||||
ret->port = atoi(optarg);
|
||||
break;
|
||||
case 'n':
|
||||
ret->name = std::string(optarg);
|
||||
break;
|
||||
case '?':
|
||||
std::cerr << "Unkown option: " << (char)optopt << "\n";
|
||||
case 'h':
|
||||
|
@ -12,10 +12,11 @@
|
||||
///////////////////////////////////////
|
||||
// cli options
|
||||
|
||||
constexpr char optarg_string[] = "p:h";
|
||||
constexpr char optarg_string[] = "n:p:h";
|
||||
|
||||
struct option_flags {
|
||||
uint16_t port;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
void help(char*);
|
||||
|
Loading…
Reference in New Issue
Block a user