Skip to content

Commit

Permalink
Move fetching quotes info to gnc-commands
Browse files Browse the repository at this point in the history
It needs gnc-prefs which I don't want to add by default to gnucash-cli.
  • Loading branch information
gjanssens authored and jralls committed Oct 2, 2022
1 parent 6ecc1ef commit 5c13da0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
19 changes: 1 addition & 18 deletions gnucash/gnucash-cli.cpp
Expand Up @@ -131,24 +131,7 @@ Gnucash::GnucashCli::start ([[maybe_unused]] int argc, [[maybe_unused]] char **a
{
if (*m_quotes_cmd == "info")
{
GncQuotes quotes;
if (quotes.cmd_result() == 0)
{
std::cout << bl::format (bl::translate ("Found Finance::Quote version {1}.")) % quotes.version() << "\n";
std::cout << bl::translate ("Finance::Quote sources: ");
for (auto source : quotes.sources())
std::cout << source << " ";
std::cout << std::endl;
return 0;
}
else
{
std::cerr << bl::translate ("Finance::Quote isn't "
"installed properly.") << "\n";
std::cerr << bl::translate ("Error message:") << "\n";
std::cerr << quotes.error_msg() << std::endl;
return 1;
}
return Gnucash::quotes_info ();
}
else if (*m_quotes_cmd == "get")
{
Expand Down
24 changes: 24 additions & 0 deletions gnucash/gnucash-commands.cpp
Expand Up @@ -352,6 +352,30 @@ scm_report_list ([[maybe_unused]] void *data,
return;
}

int
Gnucash::quotes_info (void)
{
gnc_prefs_init ();
GncQuotes quotes;
if (quotes.cmd_result() == 0)
{
std::cout << bl::format (bl::translate ("Found Finance::Quote version {1}.")) % quotes.version() << "\n";
std::cout << bl::translate ("Finance::Quote sources: ");
for (auto source : quotes.sources())
std::cout << source << " ";
std::cout << std::endl;
return 0;
}
else
{
std::cerr << bl::translate ("Finance::Quote isn't "
"installed properly.") << "\n";
std::cerr << bl::translate ("Error message:") << "\n";
std::cerr << quotes.error_msg() << std::endl;
return 1;
}
}

int
Gnucash::add_quotes (const bo_str& uri)
{
Expand Down
1 change: 1 addition & 0 deletions gnucash/gnucash-commands.hpp
Expand Up @@ -32,6 +32,7 @@ using bo_str = boost::optional <std::string>;

namespace Gnucash {

int quotes_info (void);
int add_quotes (const bo_str& uri);
int run_report (const bo_str& file_to_load,
const bo_str& run_report,
Expand Down

0 comments on commit 5c13da0

Please sign in to comment.