1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-05-01 05:03:52 +00:00

removing added pname from helpstring for optional

This commit is contained in:
Henry Fredrick Schreiner 2017-02-08 20:27:57 -05:00
parent 9b31ef38d8
commit cf667f28a9

View File

@ -159,10 +159,10 @@ public:
return false; return false;
} }
/// Gets a , sep list of names. Does not include the positional name. /// Gets a , sep list of names. Does not include the positional name if opt_only=true.
std::string get_name() const { std::string get_name(bool opt_only=false) const {
std::vector<std::string> name_list; std::vector<std::string> name_list;
if(pname.length() > 0) if(!opt_only && pname.length() > 0)
name_list.push_back(pname); name_list.push_back(pname);
for(const std::string& sname : snames) for(const std::string& sname : snames)
name_list.push_back("-"+sname); name_list.push_back("-"+sname);
@ -212,24 +212,10 @@ public:
return out; return out;
} }
/// Diagnostic representation
std::string string() const {
std::string val = "Option: " + get_name() + "\n"
+ " " + description + "\n"
+ " [";
for(const auto& item : results) {
if(&item!=&results[0])
val+="],[";
val += detail::join(item);
}
val += "]";
return val;
}
/// The first half of the help print, name plus default, etc /// The first half of the help print, name plus default, etc
std::string help_name() const { std::string help_name() const {
std::stringstream out; std::stringstream out;
out << get_name(); out << get_name(true);
if(get_expected() != 0) { if(get_expected() != 0) {
if(typeval != "") if(typeval != "")
out << " " << typeval; out << " " << typeval;