gnucash master: Bug 797800 - [help screen items] clarification welcome
Geert Janssens
gjanssens at code.gnucash.org
Fri Jun 12 11:43:54 EDT 2020
Updated via https://github.com/Gnucash/gnucash/commit/49e394e3 (commit)
from https://github.com/Gnucash/gnucash/commit/7754f035 (commit)
commit 49e394e3bdd639a6e6927ef29f3c5ccefc4f2e98
Author: Geert Janssens <geert at kobaltwit.be>
Date: Fri Jun 12 17:43:40 2020 +0200
Bug 797800 - [help screen items] clarification welcome
This fixes the presence of the 'input-file' command line option.
It's an implementation detail that wasn't meant to be listed in help.
The way to fix it is keeping two option_description variables. One
with all possible values to parse and one with only those to present
to the user
diff --git a/gnucash/gnucash-cli.cpp b/gnucash/gnucash-cli.cpp
index 03e98c6e3..ec2a34a3d 100644
--- a/gnucash/gnucash-cli.cpp
+++ b/gnucash/gnucash-cli.cpp
@@ -95,7 +95,8 @@ Gnucash::GnucashCli::configure_program_options (void)
" get: \tFetch current quotes for all foreign currencies and stocks in the given GnuCash datafile.\n"))
("namespace", bpo::value (&m_namespace),
_("Regular expression determining which namespace commodities will be retrieved for"));
- m_opt_desc->add (quotes_options);
+ m_opt_desc_display->add (quotes_options);
+ m_opt_desc_all.add (quotes_options);
bpo::options_description report_options(_("Report Generation Options"));
report_options.add_options()
@@ -110,7 +111,8 @@ Gnucash::GnucashCli::configure_program_options (void)
_("Specify export type\n"))
("output-file", bpo::value (&m_output_file),
_("Output file for report\n"));
- m_opt_desc->add (report_options);
+ m_opt_desc_display->add (report_options);
+ m_opt_desc_all.add (report_options);
}
@@ -124,14 +126,14 @@ Gnucash::GnucashCli::start ([[maybe_unused]] int argc, [[maybe_unused]] char **a
if (*m_quotes_cmd != "get")
{
std::cerr << bl::format (bl::translate("Unknown quotes command '{1}'")) % *m_quotes_cmd << "\n\n"
- << *m_opt_desc.get();
+ << *m_opt_desc_display.get();
return 1;
}
if (!m_file_to_load || m_file_to_load->empty())
{
std::cerr << bl::translate("Missing data file parameter") << "\n\n"
- << *m_opt_desc.get();
+ << *m_opt_desc_display.get();
return 1;
}
else
@@ -145,7 +147,7 @@ Gnucash::GnucashCli::start ([[maybe_unused]] int argc, [[maybe_unused]] char **a
if (!m_file_to_load || m_file_to_load->empty())
{
std::cerr << bl::translate("Missing data file parameter") << "\n\n"
- << *m_opt_desc.get();
+ << *m_opt_desc_display.get();
return 1;
}
else
@@ -163,7 +165,7 @@ Gnucash::GnucashCli::start ([[maybe_unused]] int argc, [[maybe_unused]] char **a
if (!m_report_name || m_report_name->empty())
{
std::cerr << bl::translate("Missing --name parameter") << "\n\n"
- << *m_opt_desc.get();
+ << *m_opt_desc_display.get();
return 1;
}
else
@@ -171,10 +173,14 @@ Gnucash::GnucashCli::start ([[maybe_unused]] int argc, [[maybe_unused]] char **a
else
{
std::cerr << bl::format (bl::translate("Unknown report command '{1}'")) % *m_report_cmd << "\n\n"
- << *m_opt_desc.get();
+ << *m_opt_desc_display.get();
return 1;
}
}
+
+ std::cerr << bl::translate("Missing command or option") << "\n\n"
+ << *m_opt_desc_display.get();
+
return 1;
}
diff --git a/gnucash/gnucash-core-app.cpp b/gnucash/gnucash-core-app.cpp
index a10d56abe..fc0f0793f 100644
--- a/gnucash/gnucash-core-app.cpp
+++ b/gnucash/gnucash-core-app.cpp
@@ -516,7 +516,7 @@ Gnucash::CoreApp::CoreApp (const char* app_name)
// Now that gettext is properly initialized, set our help tagline.
m_tagline = bl::translate("- GnuCash, accounting for personal and small business finance").str(gnc_get_boost_locale());
- m_opt_desc = std::make_unique<bpo::options_description>
+ m_opt_desc_display = std::make_unique<bpo::options_description>
((bl::format (bl::gettext ("{1} [options] [datafile]")) % m_app_name).str() + std::string(" ") + m_tagline);
add_common_program_options();
}
@@ -532,13 +532,13 @@ Gnucash::CoreApp::parse_command_line (int argc, char **argv)
try
{
bpo::store (bpo::command_line_parser (argc, argv).
- options (*m_opt_desc.get()).positional(m_pos_opt_desc).run(), m_opt_map);
+ options (m_opt_desc_all).positional(m_pos_opt_desc).run(), m_opt_map);
bpo::notify (m_opt_map);
}
catch (std::exception &e)
{
std::cerr << e.what() << "\n\n";
- std::cerr << *m_opt_desc.get();
+ std::cerr << *m_opt_desc_display.get() << "\n";
exit(1);
}
@@ -559,7 +559,7 @@ Gnucash::CoreApp::parse_command_line (int argc, char **argv)
if (m_show_help)
{
- std::cout << *m_opt_desc.get() << "\n";
+ std::cout << *m_opt_desc_display.get() << "\n";
exit(0);
}
@@ -589,13 +589,19 @@ Gnucash::CoreApp::add_common_program_options (void)
("logto", bpo::value (&m_log_to_filename),
_("File to log into; defaults to \"/tmp/gnucash.trace\"; can be \"stderr\" or \"stdout\"."))
("gsettings-prefix", bpo::value (&m_gsettings_prefix),
- _("Set the prefix for gsettings schemas for gsettings queries. This can be useful to have a different settings tree while debugging."))
+ _("Set the prefix for gsettings schemas for gsettings queries. This can be useful to have a different settings tree while debugging."));
+
+ bpo::options_description hidden_options(_("Hidden Options"));
+ hidden_options.add_options()
("input-file", bpo::value (&m_file_to_load),
_("[datafile]"));
m_pos_opt_desc.add("input-file", -1);
- m_opt_desc->add (common_options);
+ m_opt_desc_all.add (common_options);
+ m_opt_desc_all.add (hidden_options);
+
+ m_opt_desc_display->add (common_options);
}
void
diff --git a/gnucash/gnucash-core-app.hpp b/gnucash/gnucash-core-app.hpp
index 8b99252f5..37dea122d 100644
--- a/gnucash/gnucash-core-app.hpp
+++ b/gnucash/gnucash-core-app.hpp
@@ -51,7 +51,8 @@ protected:
boost::optional <std::string> m_log_to_filename;
boost::optional <std::string> m_file_to_load;
- std::unique_ptr<bpo::options_description> m_opt_desc;
+ bpo::options_description m_opt_desc_all;
+ std::unique_ptr<bpo::options_description> m_opt_desc_display;
bpo::variables_map m_opt_map;
bpo::positional_options_description m_pos_opt_desc;
diff --git a/gnucash/gnucash.cpp b/gnucash/gnucash.cpp
index 6b3bfdf8d..62a7c583c 100644
--- a/gnucash/gnucash.cpp
+++ b/gnucash/gnucash.cpp
@@ -343,7 +343,8 @@ Gnucash::Gnucash::configure_program_options (void)
"Note this option has been deprecated and will be removed in GnuCash 5.0.\n"
"Please use 'gnucash-cli --quotes get --namespace <namespace> <datafile>' instead."));
- m_opt_desc->add (app_options).add (depr_options);
+ m_opt_desc_display->add (app_options).add (depr_options);
+ m_opt_desc_all.add (app_options).add (depr_options);
}
int
@@ -360,7 +361,7 @@ Gnucash::Gnucash::start ([[maybe_unused]] int argc, [[maybe_unused]] char **argv
if (!m_file_to_load || m_file_to_load->empty())
{
std::cerr << bl::translate("Missing data file parameter") << "\n\n"
- << *m_opt_desc.get();
+ << *m_opt_desc_display.get();
return 1;
}
else
Summary of changes:
gnucash/gnucash-cli.cpp | 20 +++++++++++++-------
gnucash/gnucash-core-app.cpp | 18 ++++++++++++------
gnucash/gnucash-core-app.hpp | 3 ++-
gnucash/gnucash.cpp | 5 +++--
4 files changed, 30 insertions(+), 16 deletions(-)
More information about the gnucash-changes
mailing list