Skip to content

Commit 0b525e9

Browse files
authored
Merge pull request #109 from polycube-network/pr/fix_list_autocompletion
polycubed: fix list autocompletion
2 parents a36d446 + 3a890a8 commit 0b525e9

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/polycubed/src/server/Resources/Endpoint/ListResource.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ Response ListResource::Completion(const std::string &cube_name, HelpType type,
327327

328328
auto size_keys = list_keys.size();
329329
std::string keyname = keys_[size_keys].Name();
330+
std::string original_keyname = keys_[size_keys].OriginalName();
330331

331332
nlohmann::json val = nlohmann::json::array();
332333

@@ -349,7 +350,7 @@ Response ListResource::Completion(const std::string &cube_name, HelpType type,
349350
}
350351

351352
if (found) {
352-
val += item.at(keyname);
353+
val += item.at(original_keyname);
353354
}
354355
}
355356

@@ -359,11 +360,14 @@ Response ListResource::Completion(const std::string &cube_name, HelpType type,
359360
case HelpType::DEL:
360361
break;
361362
case HelpType::NONE:
362-
if (configuration_) {
363-
val += "add";
364-
val += "del";
363+
// suggest these commands only if we are not in the middle of a list
364+
if (list_keys.size() == 0) {
365+
if (configuration_) {
366+
val += "add";
367+
val += "del";
368+
}
369+
val += "show";
365370
}
366-
val += "show";
367371
break;
368372
default:
369373
return {kBadRequest, nullptr};

0 commit comments

Comments
 (0)