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

Making positional types clearer

This commit is contained in:
Henry Fredrick Schreiner 2017-02-07 15:00:24 -05:00
parent feaabb4fb3
commit b459d4782d
3 changed files with 17 additions and 3 deletions

View File

@ -1,7 +1,7 @@
## Version 0.3 (in progress)
* Supports GCC 4.7 again
* TODO: Support type and set syntax in positionals
* Support type and set syntax in positionals
* Changes `setup` for an explicit help bool in constructor/`add_subcommand`

View File

@ -547,7 +547,7 @@ public:
out << "Positionals:" << std::endl;
for(const Option_p &opt : options)
if(opt->get_positional() && opt->has_description())
detail::format_help(out, opt->get_pname(), opt->get_description(), wid);
detail::format_help(out, opt->help_pname(), opt->get_description(), wid);
out << std::endl;
}

View File

@ -135,7 +135,6 @@ public:
std::string get_pname() const {
return pname;
}
/// Process the callback
bool run_callback() const {
if(_validators.size()>0) {
@ -241,6 +240,21 @@ public:
}
return out.str();
}
/// pname with type info
std::string help_pname() const {
std::stringstream out;
out << get_pname();
if(typeval != "")
out << " " << typeval;
if(defaultval != "")
out << "=" << defaultval;
if(get_expected() > 1)
out << " x " << get_expected();
if(get_expected() == -1)
out << " ...";
return out.str();
}
/// Produce a flattened vector of results, vs. a vector of vectors.
std::vector<std::string> flatten_results() const {