tools: alias 'nfdc cs' to 'nfdc cs info'
Change-Id: Ied1d34a84110ee0b6488d35d56fb1caecaf14117
Refs: #4498
diff --git a/tools/nfdc/command-parser.cpp b/tools/nfdc/command-parser.cpp
index 59c4912..a201272 100644
--- a/tools/nfdc/command-parser.cpp
+++ b/tools/nfdc/command-parser.cpp
@@ -114,24 +114,10 @@
const std::string& noun = tokens.size() > 0 ? tokens[0] : "";
const std::string& verb = tokens.size() > 1 ? tokens[1] : "";
- size_t nameLen = std::min<size_t>(2, tokens.size());
NDN_LOG_TRACE("parse mode=" << mode << " noun=" << noun << " verb=" << verb);
auto i = m_commands.find({noun, verb});
- if (i == m_commands.end()) {
- if (verb.empty()) {
- NDN_LOG_TRACE("fallback to noun=" << noun << " verb=list");
- i = m_commands.find({noun, "list"});
- }
- else {
- // help, exit, quit commands
- NDN_LOG_TRACE("fallback to noun=" << noun << " verb=");
- i = m_commands.find({noun, ""});
- }
- nameLen = std::min<size_t>(1, tokens.size());
- }
-
if (i == m_commands.end() || (i->second->modes & static_cast<AvailableIn>(mode)) == 0) {
BOOST_THROW_EXCEPTION(NoSuchCommandError(noun, verb));
}
@@ -139,7 +125,8 @@
const CommandDefinition& def = i->second->def;
NDN_LOG_TRACE("found command noun=" << def.getNoun() << " verb=" << def.getVerb());
- return std::make_tuple(def.getNoun(), def.getVerb(), def.parse(tokens, nameLen), i->second->execute);
+ size_t nConsumed = std::min<size_t>(2, tokens.size());
+ return std::make_tuple(def.getNoun(), def.getVerb(), def.parse(tokens, nConsumed), i->second->execute);
}
} // namespace nfdc
diff --git a/tools/nfdc/face-module.cpp b/tools/nfdc/face-module.cpp
index 560b223..93a6563 100644
--- a/tools/nfdc/face-module.cpp
+++ b/tools/nfdc/face-module.cpp
@@ -40,6 +40,7 @@
.addArg("local", ArgValueType::FACE_URI, Required::NO, Positional::NO)
.addArg("scheme", ArgValueType::STRING, Required::NO, Positional::NO, "scheme");
parser.addCommand(defFaceList, &FaceModule::list);
+ parser.addAlias("face", "list", "");
CommandDefinition defFaceShow("face", "show");
defFaceShow
diff --git a/tools/nfdc/rib-module.cpp b/tools/nfdc/rib-module.cpp
index f9d888f..a5a2454 100644
--- a/tools/nfdc/rib-module.cpp
+++ b/tools/nfdc/rib-module.cpp
@@ -40,6 +40,7 @@
.addArg("nexthop", ArgValueType::FACE_ID_OR_URI, Required::NO, Positional::YES)
.addArg("origin", ArgValueType::ROUTE_ORIGIN, Required::NO, Positional::NO);
parser.addCommand(defRouteList, &RibModule::list);
+ parser.addAlias("route", "list", "");
CommandDefinition defRouteShow("route", "show");
defRouteShow
diff --git a/tools/nfdc/status.cpp b/tools/nfdc/status.cpp
index 5365fbb..a47d12b 100644
--- a/tools/nfdc/status.cpp
+++ b/tools/nfdc/status.cpp
@@ -129,22 +129,25 @@
defStatusShow
.setTitle("print general status");
parser.addCommand(defStatusShow, bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantForwarderGeneral));
- parser.addAlias("status", "show", "list");
+ parser.addAlias("status", "show", "");
CommandDefinition defChannelList("channel", "list");
defChannelList
.setTitle("print channel list");
parser.addCommand(defChannelList, bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantChannels));
+ parser.addAlias("channel", "list", "");
CommandDefinition defFibList("fib", "list");
defFibList
.setTitle("print FIB entries");
parser.addCommand(defFibList, bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantFib));
+ parser.addAlias("fib", "list", "");
CommandDefinition defCsInfo("cs", "info");
defCsInfo
.setTitle("print CS information");
parser.addCommand(defCsInfo, bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantCs));
+ parser.addAlias("cs", "info", "");
}
} // namespace nfdc
diff --git a/tools/nfdc/strategy-choice-module.cpp b/tools/nfdc/strategy-choice-module.cpp
index 9e0031f..5f81f7a 100644
--- a/tools/nfdc/strategy-choice-module.cpp
+++ b/tools/nfdc/strategy-choice-module.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -37,6 +37,7 @@
defStrategyList
.setTitle("print strategy choices");
parser.addCommand(defStrategyList, &StrategyChoiceModule::list);
+ parser.addAlias("strategy", "list", "");
CommandDefinition defStrategyShow("strategy", "show");
defStrategyShow