diff --git a/src/main.cpp b/src/main.cpp index 5172db6..d73abe5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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; diff --git a/src/opt/parseopt.cpp b/src/opt/parseopt.cpp index 478d4dd..e0741b0 100644 --- a/src/opt/parseopt.cpp +++ b/src/opt/parseopt.cpp @@ -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': diff --git a/src/opt/parseopt.hpp b/src/opt/parseopt.hpp index d833e48..3994c46 100644 --- a/src/opt/parseopt.hpp +++ b/src/opt/parseopt.hpp @@ -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*);