tools: deprecate nfdc create and nfdc destroy
They are deprecated in favor of nfdc face create and nfdc face destroy.
There is also a minor correction to nfdc-face man page.
refs #3864
Change-Id: I038bc604304ac5650101ee2afe30753e59061632
diff --git a/tools/nfdc/available-commands.cpp b/tools/nfdc/available-commands.cpp
index cc6cecc..586da48 100644
--- a/tools/nfdc/available-commands.cpp
+++ b/tools/nfdc/available-commands.cpp
@@ -47,22 +47,27 @@
{
std::string subcommand;
std::string title;
+ std::string replacementCommand; ///< replacement for deprecated legacy subcommand
};
const std::vector<LegacyNfdcCommandDefinition> legacyNfdcSubcommands{
- {"register", "register a prefix"},
- {"unregister", "unregister a prefix"},
- {"create", "create a face"},
- {"destroy", "destroy a face"},
- {"set-strategy", "set strategy choice on namespace"},
- {"unset-strategy", "unset strategy choice on namespace"},
- {"add-nexthop", "add FIB nexthop"},
- {"remove-nexthop", "remove FIB nexthop"}
+ {"register", "register a prefix", ""},
+ {"unregister", "unregister a prefix", ""},
+ {"create", "create a face", "face create"},
+ {"destroy", "destroy a face", "face destroy"},
+ {"set-strategy", "set strategy choice on namespace", ""},
+ {"unset-strategy", "unset strategy choice on namespace", ""},
+ {"add-nexthop", "add FIB nexthop", ""},
+ {"remove-nexthop", "remove FIB nexthop", ""}
};
for (const LegacyNfdcCommandDefinition& lncd : legacyNfdcSubcommands) {
CommandDefinition def(lncd.subcommand, "");
def.setTitle(lncd.title);
def.addArg("args", ArgValueType::ANY, Required::NO, Positional::YES);
- parser.addCommand(def, &legacyNfdcMain);
+ auto modes = AVAILABLE_IN_ONE_SHOT | AVAILABLE_IN_HELP;
+ if (!lncd.replacementCommand.empty()) {
+ modes = modes & ~AVAILABLE_IN_HELP;
+ }
+ parser.addCommand(def, bind(&legacyNfdcMain, _1, lncd.replacementCommand), modes);
}
}
diff --git a/tools/nfdc/legacy-nfdc.cpp b/tools/nfdc/legacy-nfdc.cpp
index 86d9ad5..5f4f81f 100644
--- a/tools/nfdc/legacy-nfdc.cpp
+++ b/tools/nfdc/legacy-nfdc.cpp
@@ -326,8 +326,13 @@
}
void
-legacyNfdcMain(ExecuteContext& ctx)
+legacyNfdcMain(ExecuteContext& ctx, const std::string& replacementCommand)
{
+ if (!replacementCommand.empty()) {
+ std::cerr << "'nfdc " << ctx.noun << "' command is deprecated. "
+ << "Use 'nfdc " << replacementCommand << "' instead.\n";
+ }
+
LegacyNfdc p(ctx.face, ctx.keyChain);
const std::string& subcommand = ctx.noun;
diff --git a/tools/nfdc/legacy-nfdc.hpp b/tools/nfdc/legacy-nfdc.hpp
index 43e82c0..6ae9abe 100644
--- a/tools/nfdc/legacy-nfdc.hpp
+++ b/tools/nfdc/legacy-nfdc.hpp
@@ -174,7 +174,7 @@
legacyNfdcUsage();
void
-legacyNfdcMain(ExecuteContext& ctx);
+legacyNfdcMain(ExecuteContext& ctx, const std::string& replacementCommand);
} // namespace nfdc
} // namespace tools