aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/suggestions.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/suggestions.cc')
-rw-r--r--src/libutil/suggestions.cc20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/libutil/suggestions.cc b/src/libutil/suggestions.cc
index bcd93aa6b..9510a5f0c 100644
--- a/src/libutil/suggestions.cc
+++ b/src/libutil/suggestions.cc
@@ -65,27 +65,27 @@ Suggestions Suggestions::trim(int limit, int maxDistance) const
return Suggestions{res};
}
-std::string Suggestion::pretty_print() const
+std::string Suggestion::to_string() const
{
return ANSI_WARNING + filterANSIEscapes(suggestion) + ANSI_NORMAL;
}
-std::string Suggestions::pretty_print() const
+std::string Suggestions::to_string() const
{
switch (suggestions.size()) {
case 0:
return "";
case 1:
- return suggestions.begin()->pretty_print();
+ return suggestions.begin()->to_string();
default: {
std::string res = "one of ";
auto iter = suggestions.begin();
- res += iter->pretty_print(); // Iter can’t be end() because the container isn’t null
+ res += iter->to_string(); // Iter can’t be end() because the container isn’t null
iter++;
auto last = suggestions.end(); last--;
for ( ; iter != suggestions.end() ; iter++) {
res += (iter == last) ? " or " : ", ";
- res += iter->pretty_print();
+ res += iter->to_string();
}
return res;
}
@@ -101,4 +101,14 @@ Suggestions & Suggestions::operator+=(const Suggestions & other)
return *this;
}
+std::ostream & operator<<(std::ostream & str, const Suggestion & suggestion)
+{
+ return str << suggestion.to_string();
+}
+
+std::ostream & operator<<(std::ostream & str, const Suggestions & suggestions)
+{
+ return str << suggestions.to_string();
+}
+
}