38 parser.
addAlias(
"strategy",
"list",
"");
42 .
setTitle(
"show strategy choice of an entry")
48 .
setTitle(
"set strategy choice for a name prefix")
55 .
setTitle(
"clear strategy choice at a name prefix")
63 ctx.
controller.fetch<ndn::nfd::StrategyChoiceDataset>(
64 [&] (
const std::vector<StrategyChoice>& dataset) {
65 for (
const StrategyChoice& entry : dataset) {
73 ctx.
face.processEvents();
79 auto prefix = ctx.
args.
get<Name>(
"prefix");
81 ctx.
controller.fetch<ndn::nfd::StrategyChoiceDataset>(
82 [&] (
const std::vector<StrategyChoice>& dataset) {
84 for (
const StrategyChoice& entry : dataset) {
85 if (entry.getName().isPrefixOf(prefix) &&
86 entry.getName().size() >= match.getName().size()) {
95 ctx.
face.processEvents();
101 auto prefix = ctx.
args.
get<Name>(
"prefix");
102 auto strategy = ctx.
args.
get<Name>(
"strategy");
104 ctx.
controller.start<ndn::nfd::StrategyChoiceSetCommand>(
105 ControlParameters().setName(prefix).setStrategy(strategy),
106 [&] (
const ControlParameters& resp) {
107 ctx.
out <<
"strategy-set ";
109 ctx.
out << ia(
"prefix") << resp.getName()
110 << ia(
"strategy") << resp.getStrategy() <<
'\n';
112 [&] (
const ControlResponse& resp) {
113 if (resp.getCode() == 404) {
115 ctx.
err <<
"Unknown strategy: " << strategy <<
'\n';
123 ctx.
face.processEvents();
129 auto prefix = ctx.
args.
get<Name>(
"prefix");
131 if (prefix.empty()) {
133 ctx.
err <<
"Unsetting default strategy is prohibited\n";
137 ctx.
controller.start<ndn::nfd::StrategyChoiceUnsetCommand>(
138 ControlParameters().setName(prefix),
139 [&] (
const ControlParameters& resp) {
140 ctx.
out <<
"strategy-unset ";
142 ctx.
out << ia(
"prefix") << resp.getName() <<
'\n';
147 ctx.
face.processEvents();
152 const std::function<
void()>& onSuccess,
153 const Controller::DatasetFailCallback& onFailure,
154 const CommandOptions& options)
156 controller.fetch<ndn::nfd::StrategyChoiceDataset>(
157 [
this, onSuccess] (
const std::vector<StrategyChoice>& result) {
167 os <<
"<strategyChoices>";
168 for (
const StrategyChoice& item : m_status) {
171 os <<
"</strategyChoices>";
177 os <<
"<strategyChoice>";
178 os <<
"<namespace>" <<
xml::Text{item.getName().toUri()} <<
"</namespace>";
179 os <<
"<strategy><name>" <<
xml::Text{item.getStrategy().toUri()} <<
"</name></strategy>";
180 os <<
"</strategyChoice>";
186 os <<
"Strategy choices:\n";
187 for (
const StrategyChoice& item : m_status) {
198 os << ia(
"prefix") << item.getName()
199 << ia(
"strategy") << item.getStrategy()
Context for command execution.
std::ostream & out
output stream
Controller::DatasetFailCallback makeDatasetFailureHandler(const std::string &datasetName)
const CommandArguments & args
int exitCode
program exit code
Controller::CommandFailCallback makeCommandFailureHandler(const std::string &commandName)
ndn::nfd::CommandOptions makeCommandOptions() const
std::ostream & err
error stream
Print attributes of an item.