tools: Fixing help message printing in nfd-status
Change-Id: I937e317b02989aa9f51168e101d203ecd9199de8
Refs: #1395
diff --git a/tools/nfd-autoreg.cpp b/tools/nfd-autoreg.cpp
index ec64a55..9ed5840 100644
--- a/tools/nfd-autoreg.cpp
+++ b/tools/nfd-autoreg.cpp
@@ -153,13 +153,14 @@
void
- usage(const po::options_description& optionDesciption,
+ usage(std::ostream& os,
+ const po::options_description& optionDesciption,
const char* programName)
{
- std::cerr << "General Usage\n "
- << programName << " --prefix=</autoreg/prefix> [--prefix=/another/prefix] ..."
- << std::endl << std::endl;
- std::cerr << optionDesciption << std::endl;
+ os << "Usage:\n"
+ << " " << programName << " --prefix=</autoreg/prefix> [--prefix=/another/prefix] ...\n"
+ << "\n";
+ os << optionDesciption;
}
void
@@ -234,20 +235,20 @@
catch (std::exception& e)
{
std::cerr << "ERROR: " << e.what() << std::endl << std::endl;
- usage(optionDesciption, argv[0]);
+ usage(std::cerr, optionDesciption, argv[0]);
return 1;
}
if (options.count("help"))
{
- usage(optionDesciption, argv[0]);
+ usage(std::cout, optionDesciption, argv[0]);
return 0;
}
if (m_autoregPrefixes.empty())
{
std::cerr << "ERROR: at least one --prefix must be specified" << std::endl << std::endl;
- usage(optionDesciption, argv[0]);
+ usage(std::cerr, optionDesciption, argv[0]);
return 2;
}
diff --git a/tools/nfd-status.cpp b/tools/nfd-status.cpp
index ff6316f..b15df61 100644
--- a/tools/nfd-status.cpp
+++ b/tools/nfd-status.cpp
@@ -30,16 +30,15 @@
void
usage()
{
- std::cout << "\nUsage: " << m_toolName << " [options]\n"
- "Shows NFD Status Information\n"
- "Displays Version Information (NFD Version, Start Timestamp, Current Timestamp).\n"
- "Face Status Information via NFD Face Status Protocol (FaceID, URI, Counters).\n"
- "FIB Information via NFD FIB Enumeration Protocol (Prefix, Nexthop).\n"
- "If no options are provided, all information is retrieved.\n"
+ std::cout << "Usage: \n " << m_toolName << " [options]\n\n"
+ "Show NFD version and status information\n\n"
+ "Options:\n"
+ " [-h] - print this help message\n"
" [-v] - retrieve version information\n"
" [-f] - retrieve face status information\n"
- " [-b] - retrieve FIB information\n"
- " [-h] - print help and exit\n\n";
+ " [-b] - retrieve FIB information\n\n"
+ "If no options are provided, all information is retrieved.\n"
+ ;
}
void
@@ -288,7 +287,7 @@
switch (option) {
case 'h':
nfdStatus.usage();
- break;
+ return 0;
case 'v':
nfdStatus.enableVersionRetrieval();
break;