tools: nfdc status commands
These commands are added to nfdc:
status show
face list
channel list
strategy list
fib list
route list
They are implemented by calling into legacy nfd-status procedures,
and currently do not support filtering arguments.
Future commits will re-implement them directly with StatusReport.
refs #3749
Change-Id: I11f3f074966649c3732969ffa22f9b3938bb4bac
diff --git a/tools/nfdc/available-commands.cpp b/tools/nfdc/available-commands.cpp
index 99a53e0..b0a118a 100644
--- a/tools/nfdc/available-commands.cpp
+++ b/tools/nfdc/available-commands.cpp
@@ -47,6 +47,12 @@
}
static int
+statusList(ExecuteContext& ctx, const std::string& option)
+{
+ return statusMain(std::vector<std::string>{option}, ctx.face, ctx.keyChain);
+}
+
+static int
legacyNfdStatus(ExecuteContext& ctx)
{
auto args = ctx.args.get<std::vector<std::string>>("args");
@@ -61,6 +67,26 @@
.addArg("format", ArgValueType::REPORT_FORMAT, Required::NO, Positional::YES);
parser.addCommand(defStatusReport, &statusReport);
+ struct StatusCommandDefinition
+ {
+ std::string noun;
+ std::string verb;
+ std::string legacyOption;
+ };
+ const std::vector<StatusCommandDefinition> statusCommands{
+ {"status", "show", "-v"},
+ {"face", "list", "-f"},
+ {"channel", "list", "-c"},
+ {"strategy", "list", "-s"},
+ {"fib", "list", "-b"},
+ {"route", "list", "-r"}
+ };
+ for (const StatusCommandDefinition& scd : statusCommands) {
+ CommandDefinition def(scd.noun, scd.verb);
+ parser.addCommand(def, bind(&statusList, _1, scd.legacyOption));
+ }
+ parser.addAlias("status", "show", "list");
+
CommandDefinition defLegacyNfdStatus("legacy-nfd-status", "");
defLegacyNfdStatus
.addArg("args", ArgValueType::ANY, Required::NO, Positional::YES);