tools: nfdc creates Face and KeyChain in main function
refs #3749
Change-Id: I169ad766634371b0192ebae640355298b78aaaa4
diff --git a/tools/nfdc/available-commands.cpp b/tools/nfdc/available-commands.cpp
index 3b6a393..99a53e0 100644
--- a/tools/nfdc/available-commands.cpp
+++ b/tools/nfdc/available-commands.cpp
@@ -32,36 +32,25 @@
namespace tools {
namespace nfdc {
-static void
-statusReport(const CommandArguments& ca)
+static int
+statusReport(ExecuteContext& ctx)
{
- int res = 1;
- ReportFormat fmt = ca.get<ReportFormat>("format", ReportFormat::TEXT);
+ ReportFormat fmt = ctx.args.get<ReportFormat>("format", ReportFormat::TEXT);
switch (fmt) {
case ReportFormat::XML:
- res = statusMain(std::vector<std::string>{"-x"});
- break;
+ return statusMain(std::vector<std::string>{"-x"}, ctx.face, ctx.keyChain);
case ReportFormat::TEXT:
- res = statusMain(std::vector<std::string>{});
- break;
+ return statusMain(std::vector<std::string>{}, ctx.face, ctx.keyChain);
}
- exit(res);
+ BOOST_ASSERT(false);
+ return 1;
}
-static void
-legacyNfdStatus(const CommandArguments& ca)
+static int
+legacyNfdStatus(ExecuteContext& ctx)
{
- std::vector<std::string> args = ca.get<std::vector<std::string>>("args");
- int res = statusMain(args);
- exit(res);
-}
-
-static void
-legacyNfdc(const std::string& subcommand, const CommandArguments& ca)
-{
- std::vector<std::string> args = ca.get<std::vector<std::string>>("args");
- int res = legacyNfdcMain(subcommand, args);
- exit(res);
+ auto args = ctx.args.get<std::vector<std::string>>("args");
+ return statusMain(args, ctx.face, ctx.keyChain);
}
void
@@ -90,7 +79,7 @@
for (const std::string& subcommand : legacyNfdcSubcommands) {
CommandDefinition def(subcommand, "");
def.addArg("args", ArgValueType::ANY, Required::NO, Positional::YES);
- parser.addCommand(def, bind(&legacyNfdc, subcommand, _1));
+ parser.addCommand(def, &legacyNfdcMain);
}
}