diff options
Diffstat (limited to 'src/libutil/args.cc')
-rw-r--r-- | src/libutil/args.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/libutil/args.cc b/src/libutil/args.cc index 2930913d6..348f1bca0 100644 --- a/src/libutil/args.cc +++ b/src/libutil/args.cc @@ -29,7 +29,16 @@ void Args::removeFlag(const std::string & longName) void Completions::add(std::string completion, std::string description) { - assert(description.find('\n') == std::string::npos); + // strip whitespace/empty lines from the front of the description + description.erase(0, description.find_first_not_of(" \t\n")); + // ellipsize overflowing content on the back of the description + auto end_index = description.find_first_of(".\n"); + if (end_index != std::string::npos) { + auto needs_ellipsis = end_index != description.size() - 1; + description.resize(end_index); + if (needs_ellipsis) + description.append(" [...]"); + } insert(Completion { .completion = completion, .description = description |