tools: add exit code and streams to nfdc::ExecuteContext

Moving exit code to the context allows error handling routines to
rely only on the context.

Moving stdout and stderr streams to the context allows mocking in
unit tests, and allows sending output to a buffer for pre-processing
when we implement interactive mode.

refs #3864

Change-Id: Ibf59c12405d0eaca0597835cb2e30125b7f70adb
diff --git a/tools/nfdc/status.cpp b/tools/nfdc/status.cpp
index c14faa3..e7de814 100644
--- a/tools/nfdc/status.cpp
+++ b/tools/nfdc/status.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2016,  Regents of the University of California,
+ * Copyright (c) 2014-2017,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -37,7 +37,7 @@
 namespace tools {
 namespace nfdc {
 
-int
+void
 reportStatus(ExecuteContext& ctx, const StatusReportOptions& options)
 {
   unique_ptr<Validator> validator = make_unique<ndn::ValidatorNull>();
@@ -75,46 +75,45 @@
 
   uint32_t code = report.collect(ctx.face, ctx.keyChain, *validator, ctrlOptions);
   if (code != 0) {
+    ctx.exitCode = 1;
     // Give a simple error code for end user.
     // Technical support personnel:
     // 1. get the exact command from end user
     // 2. code div 1000000 is zero-based section index
     // 3. code mod 1000000 is a Controller.fetch error code
-    std::cerr << "Error while collecting status report (" << code << ").\n";
-    return 1;
+    ctx.err << "Error while collecting status report (" << code << ").\n";
   }
 
   switch (options.output) {
     case ReportFormat::XML:
-      report.formatXml(std::cout);
+      report.formatXml(ctx.out);
       break;
     case ReportFormat::TEXT:
-      report.formatText(std::cout);
+      report.formatText(ctx.out);
       break;
   }
-  return 0;
 }
 
 /** \brief single-section status command
  */
-static int
+static void
 reportStatusSingleSection(ExecuteContext& ctx, bool StatusReportOptions::*wantSection)
 {
   StatusReportOptions options;
   options.*wantSection = true;
-  return reportStatus(ctx, options);
+  reportStatus(ctx, options);
 }
 
 /** \brief the 'status report' command
  */
-static int
+static void
 reportStatusComprehensive(ExecuteContext& ctx)
 {
   StatusReportOptions options;
   options.output = ctx.args.get<ReportFormat>("format", ReportFormat::TEXT);
   options.wantForwarderGeneral = options.wantChannels = options.wantFaces =
     options.wantFib = options.wantRib = options.wantStrategyChoice = true;
-  return reportStatus(ctx, options);
+  reportStatus(ctx, options);
 }
 
 void