pingserver: change the short form of --freshness to -f
-x is still accepted but will print a deprecation warning
Change-Id: Ibc2e9750006a450c85d19c432ec1a02416cdc174
diff --git a/tools/ping/server/main.cpp b/tools/ping/server/main.cpp
index 9aa7261..dcce849 100644
--- a/tools/ping/server/main.cpp
+++ b/tools/ping/server/main.cpp
@@ -105,10 +105,10 @@
po::options_description visibleDesc("Options");
visibleDesc.add_options()
("help,h", "print this help message and exit")
- ("freshness,x", po::value<time::milliseconds::rep>()->default_value(options.freshnessPeriod.count()),
+ ("freshness,f", po::value<time::milliseconds::rep>()->default_value(options.freshnessPeriod.count()),
"FreshnessPeriod of the ping response, in milliseconds")
("satisfy,p", po::value(&nMaxPings)->default_value(nMaxPings),
- "maximum number of pings to be satisfied (0=infinite)")
+ "maximum number of pings to satisfy (0 = no limit)")
("size,s", po::value(&payloadSize)->default_value(payloadSize),
"size of response payload")
("timestamp,t", po::bool_switch(&options.wantTimestamp),
@@ -122,11 +122,16 @@
hiddenDesc.add_options()
("prefix", po::value<std::string>(&prefix));
- po::positional_options_description posDesc;
- posDesc.add("prefix", -1);
+ po::options_description deprecatedDesc;
+ deprecatedDesc.add_options()
+ ("_deprecated_freshness_,x", po::value<time::milliseconds::rep>())
+ ;
po::options_description optDesc;
- optDesc.add(visibleDesc).add(hiddenDesc);
+ optDesc.add(visibleDesc).add(hiddenDesc).add(deprecatedDesc);
+
+ po::positional_options_description posDesc;
+ posDesc.add("prefix", -1);
po::variables_map vm;
try {
@@ -144,6 +149,11 @@
return 2;
}
+ if (vm.count("_deprecated_freshness_") > 0) {
+ std::cerr << "WARNING: short option '-x' is deprecated and will be removed in the near "
+ "future. Please use '-f' or the long form '--freshness'." << std::endl;
+ }
+
if (vm.count("help") > 0) {
usage(std::cout, argv[0], visibleDesc);
return 0;
@@ -162,6 +172,9 @@
options.prefix = prefix;
options.freshnessPeriod = time::milliseconds(vm["freshness"].as<time::milliseconds::rep>());
+ if (vm.count("_deprecated_freshness_") > 0) {
+ options.freshnessPeriod = time::milliseconds(vm["_deprecated_freshness_"].as<time::milliseconds::rep>());
+ }
if (options.freshnessPeriod < 0_ms) {
std::cerr << "ERROR: FreshnessPeriod cannot be negative" << std::endl;
return 2;