tools: add reliability option to nfdc face create
add LpReliability flag to FaceManager face status output
refs #4004
Change-Id: Ibcdfe7ff0fc9790cbcc4f2aa5e57e27b8a76023c
diff --git a/tools/nfdc/command-definition.cpp b/tools/nfdc/command-definition.cpp
index a2ceb33..27b30f2 100644
--- a/tools/nfdc/command-definition.cpp
+++ b/tools/nfdc/command-definition.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
@@ -40,6 +40,8 @@
return os << "none";
case ArgValueType::ANY:
return os << "any";
+ case ArgValueType::BOOLEAN:
+ return os << "boolean";
case ArgValueType::UNSIGNED:
return os << "non-negative integer";
case ArgValueType::STRING:
@@ -68,6 +70,8 @@
return "";
case ArgValueType::ANY:
return "args";
+ case ArgValueType::BOOLEAN:
+ return "bool";
case ArgValueType::UNSIGNED:
return "uint";
case ArgValueType::STRING:
@@ -138,7 +142,7 @@
const Arg& arg = namedArg->second;
if (arg.valueType == ArgValueType::NONE) {
ca[arg.name] = true;
- NDN_LOG_TRACE(token << " is a boolean argument");
+ NDN_LOG_TRACE(token << " is a no-param argument");
}
else if (i + 1 >= tokens.size()) {
BOOST_THROW_EXCEPTION(Error(arg.name + ": " + arg.metavar + " is missing"));
@@ -212,6 +216,18 @@
return ca;
}
+static bool
+parseBoolean(const std::string& s)
+{
+ if (s == "on" || s == "true" || s == "enabled" || s == "yes" || s == "1") {
+ return true;
+ }
+ if (s == "off" || s == "false" || s == "disabled" || s == "no" || s == "0") {
+ return false;
+ }
+ BOOST_THROW_EXCEPTION(std::invalid_argument("unrecognized boolean value '" + s + "'"));
+}
+
static FacePersistency
parseFacePersistency(const std::string& s)
{
@@ -221,7 +237,7 @@
if (s == "permanent") {
return FacePersistency::FACE_PERSISTENCY_PERMANENT;
}
- BOOST_THROW_EXCEPTION(std::invalid_argument("unrecognized FacePersistency"));
+ BOOST_THROW_EXCEPTION(std::invalid_argument("unrecognized FacePersistency '" + s + "'"));
}
boost::any
@@ -233,11 +249,15 @@
BOOST_ASSERT(false);
return boost::any();
+ case ArgValueType::BOOLEAN: {
+ return parseBoolean(token);
+ }
+
case ArgValueType::UNSIGNED: {
// boost::lexical_cast<uint64_t> will accept negative number
int64_t v = boost::lexical_cast<int64_t>(token);
if (v < 0) {
- BOOST_THROW_EXCEPTION(std::out_of_range("value is negative"));
+ BOOST_THROW_EXCEPTION(std::out_of_range("value '" + token + "' is negative"));
}
return static_cast<uint64_t>(v);
}