summaryrefslogtreecommitdiffstats
path: root/trace
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2019-09-04 14:03:12 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2019-09-04 14:03:26 +0200
commit876ace89bcaa76c1596f3cbe927a28da751948fa (patch)
tree6e0d20cbecf74e848055b63a3b788badc51a0484 /trace
parentrecord: Simplify content and packet size (diff)
downloadrtems-tools-876ace89bcaa76c1596f3cbe927a28da751948fa.tar.bz2
record: Simplify command line options
Update #3665.
Diffstat (limited to 'trace')
-rw-r--r--trace/record/record-main-lttng.cc26
1 files changed, 18 insertions, 8 deletions
diff --git a/trace/record/record-main-lttng.cc b/trace/record/record-main-lttng.cc
index c2f399e..add84e1 100644
--- a/trace/record/record-main-lttng.cc
+++ b/trace/record/record-main-lttng.cc
@@ -545,11 +545,10 @@ static void SignalHandler(int s) {
static const struct option kLongOpts[] = {{"help", 0, NULL, 'h'},
{"host", 1, NULL, 'H'},
{"port", 1, NULL, 'p'},
- {"input", 1, NULL, 'i'},
{NULL, 0, NULL, 0}};
static void Usage(char** argv) {
- std::cout << argv[0] << "%s [--host=HOST] [--port=PORT] [--input=INPUT]"
+ std::cout << argv[0] << " [--host=HOST] [--port=PORT] [INPUT-FILE]"
<< std::endl
<< std::endl
<< "Mandatory arguments to long options are mandatory for short "
@@ -561,7 +560,7 @@ static void Usage(char** argv) {
<< std::endl
<< " -p, --port=PORT the TCP port of the record server"
<< std::endl
- << " -i, --input=INPUT the input file" << std::endl;
+ << " INPUT-FILE the input file" << std::endl;
}
int main(int argc, char** argv) {
@@ -571,7 +570,7 @@ int main(int argc, char** argv) {
int opt;
int longindex;
- while ((opt = getopt_long(argc, argv, "hH:p:i:", &kLongOpts[0],
+ while ((opt = getopt_long(argc, argv, "hH:p:", &kLongOpts[0],
&longindex)) != -1) {
switch (opt) {
case 'h':
@@ -583,14 +582,25 @@ int main(int argc, char** argv) {
case 'p':
port = (uint16_t)strtoul(optarg, NULL, 10);
break;
- case 'i':
- file = optarg;
- break;
default:
return 1;
}
}
+ if (optind == argc - 1) {
+ file = argv[optind];
+ ++optind;
+ }
+
+ if (optind != argc) {
+ std::cerr << argv[0] << ": unrecognized options:";
+ for (int i = optind; i < argc; ++i) {
+ std::cerr << " '" << argv[i] << "'";
+ }
+ std::cerr << std::endl;
+ return 1;
+ }
+
try {
GenerateMetadata();
@@ -604,7 +614,7 @@ int main(int argc, char** argv) {
client.Run();
client.Destroy();
} catch (std::exception& e) {
- std::cerr << e.what() << std::endl;
+ std::cerr << argv[0] << ": " << e.what() << std::endl;
}
return 0;