Skip to content

Commit

Permalink
Mostrar erro para lista vazia
Browse files Browse the repository at this point in the history
  • Loading branch information
dude333 committed Oct 4, 2022
1 parent 92d0e6c commit 62b9f95
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions cmd/rapina/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,18 @@ 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
}

// 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
}

Expand Down Expand Up @@ -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" {
Expand Down
6 changes: 3 additions & 3 deletions reports/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -75,15 +75,15 @@ 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)
return ""
}

if len(info) == 0 {
err = fmt.Errorf("lista vazia")
fmt.Println("[x] Lista vazia")
return ""
}

Expand Down

0 comments on commit 62b9f95

Please sign in to comment.