Convert command line option '--add-price-quotes' to '--quotes get'

This commit is contained in:
Geert Janssens
2020-06-05 18:40:41 +02:00
parent 422dca54e1
commit 451d38f6e8
2 changed files with 16 additions and 8 deletions

View File

@@ -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"

View File

@@ -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"