kjbc

A King James Bible concordance for the terminal.
git clone git://git.swab.dev/kjbc.git
Log | Files | Refs | README | LICENSE

commit ceab50011eaa4d0da1f53fd6376775464a4e2d33
parent 6f3b108b03ba31f449358117ec41c59651519b1d
Author: Jaron Swab <jaron@swab.dev>
Date:   Sun,  6 Jun 2021 14:12:22 -0400

cons.Find() now returns a slice. Instead of a pointer.

Diffstat:
Mcons/cons.go | 4++--
Mmain.go | 15+++++++--------
2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/cons/cons.go b/cons/cons.go @@ -31,7 +31,7 @@ func marshalHebrew() *Concordance { return hebrewCon } -func Find(lang, word string) (*[]Reference, error) { +func Find(lang, word string) ([]Reference, error) { var con *Concordance if lang == "greek" { con = marshalGreek() @@ -52,5 +52,5 @@ func Find(lang, word string) (*[]Reference, error) { if refs == nil { return nil, fmt.Errorf("could not find '%s', in the concordance", word) } - return refs, nil + return *refs, nil } diff --git a/main.go b/main.go @@ -26,20 +26,19 @@ func getEntryNumber(term string) { fmt.Println(err) } - if len(*data) == 1 { - for _, v := range *data { + // Output word, entry, and definition when only one entry is listed + if len(data) == 1 { + for _, v := range data { fmt.Printf("One entry found for \"%s\"...\n", term) fmt.Printf("Entry Number: %s\n", v.Number) getDefinition(v.Number) } } - for i, v := range *data { - if i > 0 { - fmt.Printf("\nEntry Number: %s\n", v.Number) - } else { - fmt.Printf("Entry Number: %s\n", v.Number) - } + fmt.Printf("\"%s\" contains more than one entry number.\n", term) + fmt.Println("Use -v to see associated verses for each entry number.") + for _, v := range data { + fmt.Printf("\nEntry Number: %s\n", v.Number) if showVerses { fmt.Printf("In Verses: ")