diff --git a/tools/nfdc/main.cpp b/tools/nfdc/main.cpp
index 74ef47d..5bc2596 100644
--- a/tools/nfdc/main.cpp
+++ b/tools/nfdc/main.cpp
@@ -27,153 +27,36 @@
 #include "status-main.hpp"
 #include "core/version.hpp"
 
-#include <boost/lexical_cast.hpp>
-
 namespace nfd {
 namespace tools {
 namespace nfdc {
 
-static void
-usage(const char* programName)
-{
-  std::cout << "Usage:\n" << programName  << " [-h] [-V] COMMAND [<Command Options>]\n"
-    "       -h print usage and exit\n"
-    "       -V print version and exit\n"
-    "\n"
-    "   COMMAND can be one of the following:\n"
-    "       register [-I] [-C] [-c cost] [-e expiration time] [-o origin] name <faceId | faceUri>\n"
-    "           register name to the given faceId or faceUri\n"
-    "           -I: unset CHILD_INHERIT flag\n"
-    "           -C: set CAPTURE flag\n"
-    "           -c: specify cost (default 0)\n"
-    "           -e: specify expiration time in ms\n"
-    "               (by default the entry remains in FIB for the lifetime of the associated face)\n"
-    "           -o: specify origin\n"
-    "               0 for Local producer applications, 128 for NLSR, 255(default) for static routes\n"
-    "       unregister [-o origin] name <faceId | faceUri>\n"
-    "           unregister name from the given faceId\n"
-    "       create [-P] <faceUri> \n"
-    "           Create a face in one of the following formats:\n"
-    "           UDP unicast:    udp[4|6]://<remote-IP-or-host>[:<remote-port>]\n"
-    "           TCP:            tcp[4|6]://<remote-IP-or-host>[:<remote-port>] \n"
-    "           -P: create permanent (instead of persistent) face\n"
-    "       destroy <faceId | faceUri> \n"
-    "           Destroy a face\n"
-    "       set-strategy <name> <strategy> \n"
-    "           Set the strategy for a namespace \n"
-    "       unset-strategy <name> \n"
-    "           Unset the strategy for a namespace \n"
-    "       add-nexthop [-c <cost>] <name> <faceId | faceUri>\n"
-    "           Add a nexthop to a FIB entry\n"
-    "           -c: specify cost (default 0)\n"
-    "       remove-nexthop <name> <faceId | faceUri> \n"
-    "           Remove a nexthop from a FIB entry\n"
-    << std::endl;
-}
-
 static int
 main(int argc, char** argv)
 {
-  ndn::Face face;
-  LegacyNfdc p(face);
-
-  p.m_programName = argv[0];
-
   if (argc < 2) {
-    usage(p.m_programName);
+    legacyNfdcUsage();
     return 0;
   }
 
-  if (strcmp(argv[1], "-h") == 0) {
-    usage(p.m_programName);
+  std::string subcommand(argv[1]);
+  std::vector<std::string> args(argv + 2, argv + argc);
+
+  if (subcommand == "-h") {
+    legacyNfdcUsage();
     return 0;
   }
 
-  if (strcmp(argv[1], "-V") == 0) {
+  if (subcommand == "-V") {
     std::cout << NFD_VERSION_BUILD_STRING << std::endl;
     return 0;
   }
 
-  if (strcmp(argv[1], "legacy-nfd-status") == 0) {
-    return statusMain(argc - 1, argv + 1);
+  if (subcommand == "legacy-nfd-status") {
+    return statusMain(args);
   }
 
-  ::optind = 2; //start reading options from 2nd argument i.e. Command
-  int opt;
-  while ((opt = ::getopt(argc, argv, "ICc:e:o:P")) != -1) {
-    switch (opt) {
-      case 'I':
-        p.m_flags = p.m_flags & ~(ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
-        break;
-
-      case 'C':
-        p.m_flags = p.m_flags | ndn::nfd::ROUTE_FLAG_CAPTURE;
-        break;
-
-      case 'c':
-        try {
-          p.m_cost = boost::lexical_cast<uint64_t>(::optarg);
-        }
-        catch (const boost::bad_lexical_cast&) {
-          std::cerr << "Error: cost must be in unsigned integer format" << std::endl;
-          return 1;
-        }
-        break;
-
-      case 'e':
-        uint64_t expires;
-        try {
-          expires = boost::lexical_cast<uint64_t>(::optarg);
-        }
-        catch (const boost::bad_lexical_cast&) {
-          std::cerr << "Error: expiration time must be in unsigned integer format" << std::endl;
-          return 1;
-        }
-        p.m_expires = ndn::time::milliseconds(expires);
-        break;
-
-      case 'o':
-        try {
-          p.m_origin = boost::lexical_cast<uint64_t>(::optarg);
-        }
-        catch (const boost::bad_lexical_cast&) {
-          std::cerr << "Error: origin must be in unsigned integer format" << std::endl;
-          return 1;
-        }
-        break;
-
-      case 'P':
-        p.m_facePersistency = ndn::nfd::FACE_PERSISTENCY_PERMANENT;
-        break;
-
-      default:
-        usage(p.m_programName);
-        return 1;
-    }
-  }
-
-  if (argc == ::optind) {
-    usage(p.m_programName);
-    return 1;
-  }
-
-  try {
-    p.m_commandLineArguments = argv + ::optind;
-    p.m_nOptions = argc - ::optind;
-
-    //argv[1] points to the command, so pass it to the dispatch
-    bool isOk = p.dispatch(argv[1]);
-    if (!isOk) {
-      usage(p.m_programName);
-      return 1;
-    }
-    face.processEvents();
-  }
-  catch (const std::exception& e) {
-    std::cerr << "ERROR: " << e.what() << std::endl;
-    return 2;
-  }
-  return 0;
+  return legacyNfdcMain(subcommand, args);
 }
 
 } // namespace nfdc
