#pragma once #include struct Config { bool verbose = false; std::string hostName = "localhost"; unsigned short port = 6856; }; const char *argp_program_version = "1.0"; const char *argp_program_bug_address = ""; static char doc[] = "Application gets messages from SerialMultiplexer bus and displays them as a desktop notification"; static char args_doc[] = ""; static struct argp_option options[] = { {"verbose", 'v', 0, 0, "Produce verbose output" }, {"host", 'H', "ADDR", 0, "Sets the host name to connect to" }, {"port", 'p', "PORT", 0, "Sets the port to connect to" }, { 0 } }; error_t parse_opt (int key, char *arg, struct argp_state *state) { Config* config = reinterpret_cast(state->input); switch (key) { case 'v': config->verbose = true; break; case 'p': config->port = atoi(arg); break; case 'H': config->hostName = arg; break; default: return ARGP_ERR_UNKNOWN; } return 0; } static struct argp argp = { options, parse_opt, args_doc, doc };