11 #include "CLI/App.hpp" 12 #include "CLI/ConfigFwd.hpp" 13 #include "CLI/StringTools.hpp" 19 std::stringstream out;
23 if(!opt->get_lnames().empty() && opt->get_configurable()) {
24 std::string name = prefix + opt->get_lnames()[0];
28 if(opt->get_type_size() != 0) {
32 value = detail::ini_join(opt->results());
35 else if(default_also && !opt->get_default_str().empty())
36 value = opt->get_default_str();
38 }
else if(opt->count() == 1) {
42 }
else if(opt->count() > 1) {
43 value = std::to_string(opt->count());
46 }
else if(opt->count() == 0 && default_also) {
51 if(write_description && opt->has_description()) {
52 if(static_cast<int>(out.tellp()) != 0) {
55 out <<
"; " << detail::fix_newlines(
"; ", opt->get_description()) << std::endl;
59 if(opt->get_items_expected() != 1)
60 out << name <<
"=" << value << std::endl;
62 out << name <<
"=" << detail::add_quotes_if_needed(value) << std::endl;
68 out <<
to_config(subcom, default_also, write_description, prefix + subcom->get_name() +
".");
std::vector< App * > get_subcommands() const
Definition: App.hpp:1405
Creates a command line program, with very few defaults.
Definition: App.hpp:59
std::vector< const Option * > get_options(const std::function< bool(const Option *)> filter={}) const
Get the list of options (user facing function, so returns raw pointers), has optional filter function...
Definition: App.hpp:1549
std::string to_config(const App *, bool default_also, bool write_description, std::string prefix) const override
Convert an app into a configuration.
Definition: Config.hpp:18
Definition: Option.hpp:206