From f5f303714c5f8303828d913da708824ec721f7dd Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Mon, 6 Jun 2022 15:42:36 +0800 Subject: [PATCH] [gnucash-core-app] "--paths" returns gnc_list_all_paths() --- gnucash/gnucash-core-app.cpp | 18 ++++++++++++++++++ gnucash/gnucash-core-app.hpp | 1 + 2 files changed, 19 insertions(+) diff --git a/gnucash/gnucash-core-app.cpp b/gnucash/gnucash-core-app.cpp index 3bbcc5f751..54c6d32e28 100644 --- a/gnucash/gnucash-core-app.cpp +++ b/gnucash/gnucash-core-app.cpp @@ -249,6 +249,22 @@ Gnucash::CoreApp::parse_command_line (int argc, char **argv) exit(1); } + if (m_show_paths) + { + auto paths { gnc_list_all_paths ()}; + std::cout << _("GnuCash Paths") << '\n'; + for (auto n = paths; n; n = n->next) + { + auto it = static_cast(n->data); + std::cout << it->env_name << ": " << it->env_path; + if (it->modifiable) + std::cout << ' ' << _("(user modifiable)"); + std::cout << '\n'; + } + g_list_free_full (paths, g_free); + exit (0); + } + if (m_show_version) { bl::format rel_fmt (bl::translate ("GnuCash {1}")); @@ -289,6 +305,8 @@ Gnucash::CoreApp::add_common_program_options (void) _("Enable extra/development/debugging features.")) ("log", bpo::value (&m_log_flags), _("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.")) + ("paths", bpo::bool_switch(&m_show_paths), + _("Show paths")) ("logto", bpo::value (&m_log_to_filename), _("File to log into; defaults to \"/tmp/gnucash.trace\"; can be \"stderr\" or \"stdout\".")); diff --git a/gnucash/gnucash-core-app.hpp b/gnucash/gnucash-core-app.hpp index 9ff91af336..b7b1bf40dc 100644 --- a/gnucash/gnucash-core-app.hpp +++ b/gnucash/gnucash-core-app.hpp @@ -62,6 +62,7 @@ private: /* Command-line option variables */ bool m_show_help = false; bool m_show_version = false; + bool m_show_paths = false; bool m_debug = false; bool m_extra = false; boost::optional m_gsettings_prefix;