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/main.cpp b/tools/nfdc/main.cpp
index da403c8..1f96c83 100644
--- a/tools/nfdc/main.cpp
+++ b/tools/nfdc/main.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,
@@ -63,8 +63,9 @@
try {
ndn::Face face;
ndn::KeyChain keyChain;
- ExecuteContext ctx{noun, verb, ca, face, keyChain};
- return execute(ctx);
+ ExecuteContext ctx{noun, verb, ca, 0, std::cout, std::cerr, face, keyChain};
+ execute(ctx);
+ return ctx.exitCode;
}
catch (const std::exception& e) {
std::cerr << e.what() << std::endl;