diff --git a/gnucash/gnucash-cli.cpp b/gnucash/gnucash-cli.cpp index c85bb7f86e..809e2230ff 100644 --- a/gnucash/gnucash-cli.cpp +++ b/gnucash/gnucash-cli.cpp @@ -97,16 +97,20 @@ Gnucash::GnucashCli::configure_program_options (void) quotes_options.add_options() ("add-price-quotes", bpo::bool_switch(), N_("Add price quotes to given GnuCash datafile.\n")) + ("namespace", bpo::value(), + N_("Regular expression determining which namespace commodities will be retrieved")); + m_opt_desc->add (quotes_options); + + bpo::options_description report_options(_("Run Report Options")); + report_options.add_options() ("run-report", bpo::value(), N_("Runs a report\n")) ("export-type", bpo::value(), N_("Specify export type\n")) ("output-file", bpo::value(), - N_("Output file for report\n")) - ("namespace", bpo::value(), - N_("Regular expression determining which namespace commodities will be retrieved")); + N_("Output file for report\n")); + m_opt_desc->add (report_options); - m_opt_desc->add (quotes_options); } int diff --git a/gnucash/gnucash-commands.cpp b/gnucash/gnucash-commands.cpp index 5db1ef0e36..61ee943181 100644 --- a/gnucash/gnucash-commands.cpp +++ b/gnucash/gnucash-commands.cpp @@ -45,10 +45,10 @@ extern "C" { namespace bl = boost::locale; struct run_report_args { - const char *file_to_load; - const char *run_report; - const char *export_type; - const char *output_file; + const std::string& file_to_load; + const std::string& run_report; + const std::string& export_type; + const std::string& output_file; }; /* This static indicates the debugging module that this .o belongs to. */ @@ -138,6 +138,7 @@ scm_run_report (void *data, scm_c_eval_string("(debug-set! stack 200000)"); scm_c_use_module ("gnucash utilities"); scm_c_use_module ("gnucash app-utils"); + scm_c_use_module ("gnucash report"); scm_c_use_module ("gnucash reports"); // gnc_report_init (); @@ -145,12 +146,13 @@ scm_run_report (void *data, // load_user_config(); gnc_prefs_init (); qof_event_suspend (); - datafile = args->file_to_load; + datafile = args->file_to_load.c_str(); cmdline = scm_c_eval_string ("gnc:cmdline-run-report"); - report = scm_from_utf8_string (args->run_report); - type = args->export_type ? scm_from_utf8_string (args->export_type) : SCM_BOOL_F; - file = args->output_file ? scm_from_utf8_string (args->output_file) : SCM_BOOL_F; + report = scm_from_utf8_string (args->run_report.c_str()); + + type = !args->export_type.empty() ? scm_from_utf8_string (args->export_type.c_str()) : SCM_BOOL_F; + file = !args->output_file.empty() ? scm_from_utf8_string (args->output_file.c_str()) : SCM_BOOL_F; /* dry-run? is #t: try report, check validity of options */ if (scm_is_false (scm_call_4 (cmdline, report, type, file, SCM_BOOL_T))) @@ -203,13 +205,13 @@ Gnucash::add_quotes (std::string &uri) } int -Gnucash::run_report (const std::string file_to_load, std::string &run_report, - std::string &export_type, std::string &output_file) +Gnucash::run_report (const std::string& file_to_load, + const std::string& run_report, + const std::string& export_type, + const std::string& output_file) { - auto args = run_report_args { file_to_load.c_str(), - run_report.c_str(), - export_type.c_str(), - output_file.c_str() }; + auto args = run_report_args { file_to_load, run_report, + export_type, output_file }; if (not run_report.empty()) scm_boot_guile (0, nullptr, scm_run_report, &args); diff --git a/gnucash/gnucash-commands.hpp b/gnucash/gnucash-commands.hpp index 8e74a51d6c..9c59d74b6e 100644 --- a/gnucash/gnucash-commands.hpp +++ b/gnucash/gnucash-commands.hpp @@ -30,8 +30,10 @@ namespace Gnucash { int add_quotes (std::string &uri); - int run_report (const std::string file_to_load, std::string &run_report, - std::string &export_type, std::string &output_file); + int run_report (const std::string& file_to_load, + const std::string& run_report, + const std::string& export_type, + const std::string& output_file); } #endif