ndnputchunks: display some output by default.

Will display some messages without the need of the '-v' parameter.
'-v' still adds the additional output per incoming Interest.

Also adds '-q' flag to disable all output except errors.

refs: #4286

Change-Id: I81116182403cd3f3e9d9bd63be64c1ff3a4552ee
diff --git a/tools/chunks/putchunks/ndnputchunks.cpp b/tools/chunks/putchunks/ndnputchunks.cpp
index 195d2ca..7dbb5a8 100644
--- a/tools/chunks/putchunks/ndnputchunks.cpp
+++ b/tools/chunks/putchunks/ndnputchunks.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2016,  Regents of the University of California,
+/*
+ * Copyright (c) 2016-2017,  Regents of the University of California,
  *                      Colorado State University,
  *                      University Pierre & Marie Curie, Sorbonne University.
  *
@@ -23,6 +23,7 @@
  * @author Wentao Shang
  * @author Steve DiBenedetto
  * @author Andrea Tosatto
+ * @author Klaus Schneider
  */
 
 #include "core/version.hpp"
@@ -50,6 +51,7 @@
   size_t maxChunkSize = MAX_NDN_PACKET_SIZE >> 1;
   std::string signingStr;
   bool isVerbose = false;
+  bool isQuiet = false;
   std::string prefix;
 
   po::options_description visibleDesc("Options");
@@ -62,7 +64,8 @@
                         "maximum chunk size, in bytes")
     ("signing-info,S",  po::value<std::string>(&signingStr)->default_value(signingStr),
                         "set signing information")
-    ("verbose,v",       po::bool_switch(&isVerbose), "turn on verbose output")
+    ("quiet,q",         po::bool_switch(&isQuiet), "turn off all non-error output")
+    ("verbose,v",       po::bool_switch(&isVerbose), "turn on verbose output (per Interest information)")
     ("version,V",       "print program version and exit")
     ;
 
@@ -110,6 +113,11 @@
     return 2;
   }
 
+  if (isQuiet && isVerbose) {
+    std::cerr << "ERROR: Cannot use flags -q and -v at the same time\n";
+    return 2;
+  }
+
   security::SigningInfo signingInfo;
   try {
     signingInfo = security::SigningInfo(signingStr);
@@ -123,7 +131,7 @@
     Face face;
     KeyChain keyChain;
     Producer producer(prefix, face, keyChain, signingInfo, time::milliseconds(freshnessPeriod),
-                      maxChunkSize, isVerbose, printVersion, std::cin);
+                      maxChunkSize, isQuiet, isVerbose, printVersion, std::cin);
     producer.run();
   }
   catch (const std::exception& e) {
diff --git a/tools/chunks/putchunks/producer.cpp b/tools/chunks/putchunks/producer.cpp
index 141be5b..5e50900 100644
--- a/tools/chunks/putchunks/producer.cpp
+++ b/tools/chunks/putchunks/producer.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2016,  Regents of the University of California,
+/*
+ * Copyright (c) 2016-2017,  Regents of the University of California,
  *                      Colorado State University,
  *                      University Pierre & Marie Curie, Sorbonne University.
  *
@@ -23,6 +23,7 @@
  * @author Wentao Shang
  * @author Steve DiBenedetto
  * @author Andrea Tosatto
+ * @author Klaus Schneider
  */
 
 #include "producer.hpp"
@@ -36,6 +37,7 @@
                    const security::SigningInfo& signingInfo,
                    time::milliseconds freshnessPeriod,
                    size_t maxSegmentSize,
+                   bool isQuiet,
                    bool isVerbose,
                    bool needToPrintVersion,
                    std::istream& is)
@@ -44,6 +46,7 @@
   , m_signingInfo(signingInfo)
   , m_freshnessPeriod(freshnessPeriod)
   , m_maxSegmentSize(maxSegmentSize)
+  , m_isQuiet(isQuiet)
   , m_isVerbose(isVerbose)
 {
   if (prefix.size() > 0 && prefix[-1].isVersion()) {
@@ -65,7 +68,7 @@
                            RegisterPrefixSuccessCallback(),
                            bind(&Producer::onRegisterFailed, this, _1, _2));
 
-  if (m_isVerbose)
+  if (!m_isQuiet)
     std::cerr << "Data published with name: " << m_versionedPrefix << std::endl;
 }
 
@@ -113,7 +116,7 @@
 {
   BOOST_ASSERT(m_store.size() == 0);
 
-  if (m_isVerbose)
+  if (!m_isQuiet)
     std::cerr << "Loading input ..." << std::endl;
 
   std::vector<uint8_t> buffer(m_maxSegmentSize);
@@ -141,7 +144,7 @@
     m_keyChain.sign(*data, m_signingInfo);
   }
 
-  if (m_isVerbose)
+  if (!m_isQuiet)
     std::cerr << "Created " << m_store.size() << " chunks for prefix " << m_prefix << std::endl;
 }
 
diff --git a/tools/chunks/putchunks/producer.hpp b/tools/chunks/putchunks/producer.hpp
index 061a2bf..86dcad7 100644
--- a/tools/chunks/putchunks/producer.hpp
+++ b/tools/chunks/putchunks/producer.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2016,  Regents of the University of California,
+/*
+ * Copyright (c) 2016-2017,  Regents of the University of California,
  *                      Colorado State University,
  *                      University Pierre & Marie Curie, Sorbonne University.
  *
@@ -23,6 +23,7 @@
  * @author Wentao Shang
  * @author Steve DiBenedetto
  * @author Andrea Tosatto
+ * @author Klaus Schneider
  */
 
 #ifndef NDN_TOOLS_CHUNKS_PUTCHUNKS_PRODUCER_HPP
@@ -51,8 +52,8 @@
    */
   Producer(const Name& prefix, Face& face, KeyChain& keyChain,
            const security::SigningInfo& signingInfo, time::milliseconds freshnessPeriod,
-           size_t maxSegmentSize, bool isVerbose = false, bool needToPrintVersion = false,
-           std::istream& is = std::cin);
+           size_t maxSegmentSize, bool isQuiet = false, bool isVerbose = false,
+           bool needToPrintVersion = false, std::istream& is = std::cin);
 
   /**
    * @brief Run the Producer
@@ -91,6 +92,7 @@
   security::SigningInfo m_signingInfo;
   time::milliseconds m_freshnessPeriod;
   size_t m_maxSegmentSize;
+  bool m_isQuiet;
   bool m_isVerbose;
 };