gnucash master: Multiple changes pushed
Geert Janssens
gjanssens at code.gnucash.org
Fri Jun 5 13:46:26 EDT 2020
Updated via https://github.com/Gnucash/gnucash/commit/cee52d4f (commit)
via https://github.com/Gnucash/gnucash/commit/451d38f6 (commit)
from https://github.com/Gnucash/gnucash/commit/422dca54 (commit)
commit cee52d4f918a62686db34174f24c24124ce9f11c
Author: Geert Janssens <geert at kobaltwit.be>
Date: Fri Jun 5 19:46:17 2020 +0200
Convert '--run-report' to '--report run' to accomodate for additonal report commands
Note this required the introduction of a '--name' parameter
for the report name to run. Without it the command line
would have to support a variable number of positional
parameters, depending on the context (quotes or report)
and that would complicate the parsing considerably.
diff --git a/gnucash/gnucash-cli.cpp b/gnucash/gnucash-cli.cpp
index c9d352653..d801473f5 100644
--- a/gnucash/gnucash-cli.cpp
+++ b/gnucash/gnucash-cli.cpp
@@ -59,7 +59,8 @@ namespace Gnucash {
boost::optional <std::string> m_quotes_cmd;
boost::optional <std::string> m_namespace;
- boost::optional <std::string> m_run_report;
+ boost::optional <std::string> m_report_cmd;
+ boost::optional <std::string> m_report_name;
boost::optional <std::string> m_export_type;
boost::optional <std::string> m_output_file;
};
@@ -90,7 +91,7 @@ Gnucash::GnucashCli::configure_program_options (void)
bpo::options_description quotes_options(_("Price Quotes Retrieval Options"));
quotes_options.add_options()
("quotes,Q", bpo::value (&m_quotes_cmd),
- _("Run price quote related commands. Currently only one command is supported.\n\n"
+ _("Execute price quote related commands. Currently only one command is supported.\n\n"
" 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"));
@@ -98,8 +99,11 @@ Gnucash::GnucashCli::configure_program_options (void)
bpo::options_description report_options(_("Report Generation Options"));
report_options.add_options()
- ("run-report", bpo::value (&m_run_report),
- _("Runs a report\n"))
+ ("report,R", bpo::value (&m_report_cmd),
+ _("Execute report related commands. Currently only one command is supported.\n\n"
+ " run: \tRun the named report in the given GnuCash datafile.\n"))
+ ("name", bpo::value (&m_report_name),
+ _("Name of the report to run\n"))
("export-type", bpo::value (&m_export_type),
_("Specify export type\n"))
("output-file", bpo::value (&m_output_file),
@@ -129,20 +133,29 @@ Gnucash::GnucashCli::start ([[maybe_unused]] int argc, [[maybe_unused]] char **a
return 1;
}
else
- return Gnucash::add_quotes (*m_file_to_load);
+ return Gnucash::add_quotes (m_file_to_load);
}
- if (m_run_report && !m_run_report->empty())
+ if (m_report_cmd)
{
- if (!m_file_to_load || m_file_to_load->empty())
+ if (*m_report_cmd == "run")
{
- std::cerr << bl::translate("Missing data file parameter") << "\n\n"
- << *m_opt_desc.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();
+ return 1;
+ }
+ else
+ return Gnucash::run_report(m_file_to_load, m_report_name,
+ m_export_type, m_output_file);
}
else
- return Gnucash::run_report(*m_file_to_load, m_run_report,
- m_export_type, m_output_file);
+ {
+ std::cerr << bl::format (bl::translate("Unknown report command '{1}'")) % *m_report_cmd << "\n\n"
+ << *m_opt_desc.get();
+ return 1;
+ }
}
return 1;
}
commit 451d38f6e8850e84961c772ef228fc76434a6a79
Author: Geert Janssens <geert at kobaltwit.be>
Date: Fri Jun 5 18:40:41 2020 +0200
Convert command line option '--add-price-quotes' to '--quotes get'
diff --git a/gnucash/gnucash-cli.cpp b/gnucash/gnucash-cli.cpp
index 31d68ffc0..c9d352653 100644
--- a/gnucash/gnucash-cli.cpp
+++ b/gnucash/gnucash-cli.cpp
@@ -56,7 +56,7 @@ namespace Gnucash {
private:
void configure_program_options (void);
- bool m_add_quotes;
+ boost::optional <std::string> m_quotes_cmd;
boost::optional <std::string> m_namespace;
boost::optional <std::string> m_run_report;
@@ -89,10 +89,11 @@ Gnucash::GnucashCli::configure_program_options (void)
{
bpo::options_description quotes_options(_("Price Quotes Retrieval Options"));
quotes_options.add_options()
- ("add-price-quotes", bpo::bool_switch (&m_add_quotes),
- _("Add price quotes to given GnuCash datafile."))
+ ("quotes,Q", bpo::value (&m_quotes_cmd),
+ _("Run price quote related commands. Currently only one command is supported.\n\n"
+ " 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"));
+ _("Regular expression determining which namespace commodities will be retrieved for"));
m_opt_desc->add (quotes_options);
bpo::options_description report_options(_("Report Generation Options"));
@@ -112,8 +113,15 @@ Gnucash::GnucashCli::start ([[maybe_unused]] int argc, [[maybe_unused]] char **a
{
Gnucash::CoreApp::start();
- if (m_add_quotes)
+ if (m_quotes_cmd)
{
+ if (*m_quotes_cmd != "get")
+ {
+ std::cerr << bl::format (bl::translate("Unknown quotes command '{1}'")) % *m_quotes_cmd << "\n\n"
+ << *m_opt_desc.get();
+ return 1;
+ }
+
if (!m_file_to_load || m_file_to_load->empty())
{
std::cerr << bl::translate("Missing data file parameter") << "\n\n"
diff --git a/gnucash/gnucash.cpp b/gnucash/gnucash.cpp
index 182e1fcf7..c0e06fff9 100644
--- a/gnucash/gnucash.cpp
+++ b/gnucash/gnucash.cpp
@@ -337,11 +337,11 @@ Gnucash::Gnucash::configure_program_options (void)
("add-price-quotes", bpo::bool_switch (&m_add_quotes),
_("Add price quotes to given GnuCash datafile.\n"
"Note this option has been deprecated and will be removed in GnuCash 5.0.\n"
- "Please use \"gnucash-cli --add-price-quotes\" instead."))
+ "Please use 'gnucash-cli --quotes get <datafile>' instead."))
("namespace", bpo::value (&m_namespace),
_("Regular expression determining which namespace commodities will be retrieved.\n"
"Note this option has been deprecated and will be removed in GnuCash 5.0.\n"
- "Please use \"gnucash-cli --add-price-quotes\" instead."));
+ "Please use 'gnucash-cli --quotes get --namespace <namespace> <datafile>' instead."));
m_opt_desc->add (app_options).add (depr_options);
}
@@ -356,7 +356,7 @@ Gnucash::Gnucash::start ([[maybe_unused]] int argc, [[maybe_unused]] char **argv
if (m_add_quotes)
{
std::cerr << bl::translate ("The '--add-price-quotes' option to gnucash has been deprecated and will be removed in GnuCash 5.0. "
- "Please use 'gnucash-cli --add-price-quotes' instead.") << "\n";
+ "Please use 'gnucash-cli --quotes get <datafile>' instead.") << "\n";
if (!m_file_to_load || m_file_to_load->empty())
{
std::cerr << bl::translate("Missing data file parameter") << "\n\n"
Summary of changes:
gnucash/gnucash-cli.cpp | 53 ++++++++++++++++++++++++++++++++++---------------
gnucash/gnucash.cpp | 6 +++---
2 files changed, 40 insertions(+), 19 deletions(-)
More information about the gnucash-changes
mailing list