Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions OptionParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,20 @@ string OptionParser::about_message() const {
static const char *PROGRAM_NAME_TAG = "PROGRAM: ";
static const std::regex whitespace_re(R"([\s]+)");

// remove newlines
string tmp_descr{prog_descr};
regex_replace(begin(tmp_descr), cbegin(tmp_descr), cend(tmp_descr),
whitespace_re, " ");
tmp_descr.erase(tmp_descr.find_last_not_of(' ') + 1);
tmp_descr.erase(0, tmp_descr.find_first_not_of(' '));

vector<string> parts;
smithlab::split_whitespace(tmp_descr, parts);
std::vector<std::string> parts = [&] {
if (prog_descr_is_raw)
return std::vector<std::string>(1, prog_descr);
// remove newlines
std::string tmp_descr{prog_descr};
std::regex_replace(std::begin(tmp_descr), std::cbegin(tmp_descr),
std::cend(tmp_descr), whitespace_re, " ");
tmp_descr.erase(tmp_descr.find_last_not_of(' ') + 1);
tmp_descr.erase(0, tmp_descr.find_first_not_of(' '));

vector<string> parts;
smithlab::split_whitespace(tmp_descr, parts);
return parts;
}();

std::ostringstream ss;
ss << PROGRAM_NAME_TAG << prog_name << endl;
Expand Down
2 changes: 2 additions & 0 deletions OptionParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ class OptionParser {
}

std::string option_missing_message() const;
void set_prog_descr_raw() { prog_descr_is_raw = true; }

static const bool OPTIONAL = false;
static const bool REQUIRED = true;

private:
std::string prog_name;
std::string prog_descr;
bool prog_descr_is_raw{};
std::string noflag_message;
std::vector<Option> options;

Expand Down