From 60da4bd7bf5b06cc93a000ed757e22a08554bf4b Mon Sep 17 00:00:00 2001 From: goodvibes2 Date: Fri, 12 Jun 2020 15:11:53 +1000 Subject: [PATCH] gnc-fq-dump: Err msg if AlphaVantage API Key is needed but missing AlphaVantage API Key is needed for all currency quotes and stock quotes with source 'alphavantage' or 'vanguard' or multi sources that include 'alphavantage' --- libgnucash/quotes/gnc-fq-dump.in | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libgnucash/quotes/gnc-fq-dump.in b/libgnucash/quotes/gnc-fq-dump.in index 6c595a8356..6f11f8d82b 100755 --- a/libgnucash/quotes/gnc-fq-dump.in +++ b/libgnucash/quotes/gnc-fq-dump.in @@ -141,6 +141,25 @@ sub report { } } +sub chk_api_key { + my $exch = $_[0]; + my $url = " https://wiki.gnucash.org/wiki/Online_Quotes#Source_Alphavantage.2C_US\n"; + if (($exch eq "currency") || ($exch eq "alphavantage") + || ($exch eq "vanguard")) { + die "ERROR: ALPHAVANTAGE_API_KEY *must* be set for currency quotes and \n" . + " stock quotes with source 'alphavantage' or 'vanguard'; see\n" . $url + unless (defined ($ENV{'ALPHAVANTAGE_API_KEY'})); + } + if (($exch eq "canada") || ($exch eq "nasdaq") + || ($exch eq "nyse") || ($exch eq "usa")) { + printf("WARNING: Multiple Source '%s' will not be able to use alphavantage " . + "unless ALPHAVANTAGE_API_KEY is set; see\n%s", $exch, $url) + unless (defined ($ENV{'ALPHAVANTAGE_API_KEY'})); + } +} + +############## end of functions - start mainline ######################### + # Check for and load non-standard modules check_modules (); @@ -162,6 +181,7 @@ if ($ARGV[0] eq "-v") { } my $exchange = shift; +chk_api_key ($exchange); if ($exchange eq "currency") { my $from = shift; while ($#ARGV >= 0) {