diff options
author | Oliver Smith <osmith@sysmocom.de> | 2018-10-23 13:12:17 +0200 |
---|---|---|
committer | osmith <osmith@sysmocom.de> | 2018-10-23 11:34:43 +0000 |
commit | a439fed1662ce92c008e440b6a2ca1b2d95ce4cb (patch) | |
tree | b73a3947e9b6dc05054b3a1bf4ebcbd7094a6e83 | |
parent | 8fb0c3dce46e553b163cc190b44f23168afc06cb (diff) |
Add long parameters (--help, --version, ...)
Makes osmo-trx-* more consistent with other Osmocom programs, and
allows an unified test for not having "UNKNOWN" in --version.
Related: OS#3578
Change-Id: I90cf01d972aa10b48c59b67a1e7f82a4255ef526
-rw-r--r-- | Transceiver52M/osmo-trx.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp index 7f72c47..b6b676e 100644 --- a/Transceiver52M/osmo-trx.cpp +++ b/Transceiver52M/osmo-trx.cpp @@ -27,6 +27,7 @@ #include <signal.h> #include <stdlib.h> #include <unistd.h> +#include <getopt.h> #include <sched.h> #include <vector> #include <string> @@ -211,9 +212,9 @@ static std::vector<std::string> comma_delimited_to_vector(char* opt) static void print_help() { fprintf(stdout, "Options:\n" - " -h This text\n" - " -C Filename The config file to use\n" - " -V Print the version of OsmoTRX\n" + " -h, --help This text\n" + " -C, --config Filename The config file to use\n" + " -V, --version Print the version of OsmoTRX\n" ); } @@ -230,8 +231,15 @@ static void handle_options(int argc, char **argv, struct trx_ctx* trx) unsigned int i; std::vector<std::string> rx_paths, tx_paths; bool rx_paths_set = false, tx_paths_set = false; - - while ((option = getopt(argc, argv, "ha:l:i:j:p:c:dmxgfo:s:b:r:A:R:Set:y:z:C:V")) != -1) { + static struct option long_options[] = { + {"help", 0, 0, 'h'}, + {"config", 1, 0, 'C'}, + {"version", 0, 0, 'V'}, + {NULL, 0, 0, 0} + }; + + while ((option = getopt_long(argc, argv, "ha:l:i:j:p:c:dmxgfo:s:b:r:A:R:Set:y:z:C:V", long_options, + NULL)) != -1) { switch (option) { case 'h': print_help(); |