From 62b9f957f10214a66c182dc34aab59c1ed42bd56 Mon Sep 17 00:00:00 2001 From: Adriano Date: Mon, 3 Oct 2022 23:57:03 -0300 Subject: [PATCH] Mostrar erro para lista vazia --- cmd/rapina/report.go | 24 ++++++++++++------------ reports/list.go | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cmd/rapina/report.go b/cmd/rapina/report.go index 34177db..112bc29 100644 --- a/cmd/rapina/report.go +++ b/cmd/rapina/report.go @@ -144,9 +144,9 @@ func SelectCompany(company string, scriptMode bool) string { // Interactive menu if len(matches) >= 1 { - result := promptUser(matches,"Selecione a Empresa") + result := promptUser(matches, "Selecione a Empresa") - tickers, err := reports.ListTickers(db,result) + tickers, err := reports.ListTickers(db, result) if err != nil { fmt.Println("[x] Recuperando lista de tickers ", err) return result @@ -154,8 +154,8 @@ func SelectCompany(company string, scriptMode bool) string { // Interactive menu if len(tickers) > 0 { - ticker := promptUser(tickers,"Selecione o ticker") - resultWithTicker := fmt.Sprintf("%s@#%s", result, reports.GetSpcfctnCd(db,result,ticker)) + ticker := promptUser(tickers, "Selecione o ticker") + resultWithTicker := fmt.Sprintf("%s@#%s", result, reports.GetSpcfctnCd(db, result, ticker)) return resultWithTicker } @@ -185,14 +185,14 @@ func Report(p Parms) (err error) { } parms := map[string]interface{}{ - "db": db, - "dataDir": dataDir, - "company": p.Company, - "SpcfctnCd":p.SpcfctnCd, - "format": p.Format, - "filename": file, - "yamlFile": p.YamlFile, - "reports": p.Reports, + "db": db, + "dataDir": dataDir, + "company": p.Company, + "SpcfctnCd": p.SpcfctnCd, + "format": p.Format, + "filename": file, + "yamlFile": p.YamlFile, + "reports": p.Reports, } if p.Format == "stdout" { diff --git a/reports/list.go b/reports/list.go index 01b565e..a825f8e 100644 --- a/reports/list.go +++ b/reports/list.go @@ -46,7 +46,7 @@ func ListCompanies(db *sql.DB) (names []string, err error) { // ListTickers shows all available tickers for a companie name // func ListTickers(db *sql.DB, companyName string) (names []string, err error) { - info, err := tickers(db,companyName) + info, err := tickers(db, companyName) if err != nil { fmt.Println("[x] Falha:", err) @@ -75,7 +75,7 @@ func ListTickers(db *sql.DB, companyName string) (names []string, err error) { // ListTickers returns SpcfctnCd of a ticker // func GetSpcfctnCd(db *sql.DB, companyName string, ticker string) string { - info, err := tickers(db,companyName) + info, err := tickers(db, companyName) if err != nil { fmt.Println("[x] Falha:", err) @@ -83,7 +83,7 @@ func GetSpcfctnCd(db *sql.DB, companyName string, ticker string) string { } if len(info) == 0 { - err = fmt.Errorf("lista vazia") + fmt.Println("[x] Lista vazia") return "" }