mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Make options that don't take arguments bool_switch type
This means they will always exist in the value store after parsing and are set to true or false. This eliminates the need to test for their existence first.
This commit is contained in:
parent
88ed957d2a
commit
160034165c
@ -587,7 +587,7 @@ Gnucash::CoreApp::parse_command_line (int argc, char **argv)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (m_opt_map.count ("version"))
|
||||
if (m_opt_map["version"].as<bool>())
|
||||
{
|
||||
bl::format rel_fmt (bl::translate ("GnuCash {1}"));
|
||||
bl::format dev_fmt (bl::translate ("GnuCash {1} development version"));
|
||||
@ -601,14 +601,14 @@ Gnucash::CoreApp::parse_command_line (int argc, char **argv)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (m_opt_map.count ("help"))
|
||||
if (m_opt_map["help"].as<bool>())
|
||||
{
|
||||
std::cout << *m_opt_desc.get() << "\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
gnc_prefs_set_debugging (m_opt_map.count ("debug"));
|
||||
gnc_prefs_set_extra (m_opt_map.count ("extra"));
|
||||
gnc_prefs_set_debugging (m_opt_map["debug"].as<bool>());
|
||||
gnc_prefs_set_extra (m_opt_map["extra"].as<bool>());
|
||||
|
||||
if (m_opt_map.count ("gsettings-prefix"))
|
||||
gnc_gsettings_set_prefix (m_opt_map["gsettings-prefix"].
|
||||
@ -630,13 +630,13 @@ Gnucash::CoreApp::add_common_program_options (void)
|
||||
|
||||
bpo::options_description common_options(_("Common Options"));
|
||||
common_options.add_options()
|
||||
("help,h",
|
||||
("help,h", bpo::bool_switch(),
|
||||
N_("Show this help message"))
|
||||
("version,v",
|
||||
("version,v", bpo::bool_switch(),
|
||||
N_("Show GnuCash version"))
|
||||
("debug",
|
||||
("debug", bpo::bool_switch(),
|
||||
N_("Enable debugging mode: provide deep detail in the logs.\nThis is equivalent to: --log \"=info\" --log \"qof=info\" --log \"gnc=info\""))
|
||||
("extra",
|
||||
("extra", bpo::bool_switch(),
|
||||
N_("Enable extra/development/debugging features."))
|
||||
("log", bpo::value< std::vector<std::string> >(),
|
||||
N_("Log level overrides, of the form \"modulename={debug,info,warn,crit,error}\"\nExamples: \"--log qof=debug\" or \"--log gnc.backend.file.sx=info\"\nThis can be invoked multiple times."))
|
||||
|
@ -381,7 +381,7 @@ Gnucash::Gnucash::parse_command_line (int argc, char **argv)
|
||||
{
|
||||
Gnucash::CoreApp::parse_command_line (argc, argv);
|
||||
|
||||
if (m_opt_map.count ("help-gtk"))
|
||||
if (m_opt_map["help-gtk"].as<bool>())
|
||||
{
|
||||
std::cout << m_gtk_help_msg;
|
||||
exit(0);
|
||||
@ -411,9 +411,10 @@ Gnucash::Gnucash::configure_program_options (void)
|
||||
|
||||
bpo::options_description app_options(_("Application Options"));
|
||||
app_options.add_options()
|
||||
("nofile",
|
||||
("nofile", bpo::bool_switch(),
|
||||
N_("Do not load the last file opened"))
|
||||
("help-gtk", _("Show help for gtk options"))
|
||||
("help-gtk", bpo::bool_switch(),
|
||||
_("Show help for gtk options"))
|
||||
("add-price-quotes", bpo::value<std::string>(),
|
||||
N_("Add price quotes to given GnuCash datafile.\n"
|
||||
"Note this option has been deprecated and will be removed in GnuCash 5.0.\n"
|
||||
|
Loading…
Reference in New Issue
Block a user