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/docs/manpages/nfdc-face.rst b/docs/manpages/nfdc-face.rst
index 46d0ef5..f393a93 100644
--- a/docs/manpages/nfdc-face.rst
+++ b/docs/manpages/nfdc-face.rst
@@ -4,9 +4,9 @@
SYNOPSIS
--------
| nfdc face [list]
-| nfdc face show <FACEID>
+| nfdc face show [id] <FACEID>
| nfdc face create [remote] <FACEURI> [[persistency] <PERSISTENCY>]
-| nfdc face destroy <FACEID|FACEURI>
+| nfdc face destroy [face] <FACEID|FACEURI>
| nfdc channel [list]
DESCRIPTION
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