Skip to content

Commit

Permalink
print the ID alongside the names/categories
Browse files Browse the repository at this point in the history
  • Loading branch information
tmck-code committed Apr 4, 2024
1 parent 5e586ef commit 592b908
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pokesay.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,12 @@ func runListNames(token string) {
// GenerateNames returns a list of names to print
// - If the japanese name flag is set, it returns both the english and japanese names
// - Otherwise, it returns just the english name
func GenerateNames(metadata pokedex.PokemonMetadata, args pokesay.Args) []string {
func GenerateNames(metadata pokedex.PokemonMetadata, args pokesay.Args, final pokedex.PokemonEntryMapping) []string {
if args.JapaneseName {
return []string{
metadata.Name,
fmt.Sprintf("%s (%s)", metadata.JapaneseName, metadata.JapanesePhonetic),
fmt.Sprintf("%s.%04d", metadata.Idx, final.EntryIndex),
}
} else {
return []string{metadata.Name}
Expand All @@ -175,7 +176,7 @@ func runPrintByName(args pokesay.Args) {
metadata, final := pokesay.ChooseByName(names, args.NameToken, GOBCowNames, MetadataRoot)
t.Mark("find/read metadata")

pokesay.Print(args, final.EntryIndex, GenerateNames(metadata, args), final.Categories, GOBCowData)
pokesay.Print(args, final.EntryIndex, GenerateNames(metadata, args, final), final.Categories, GOBCowData)
t.Mark("print")

t.Stop()
Expand Down Expand Up @@ -204,7 +205,7 @@ func runPrintByID(args pokesay.Args) {
metadata, final := pokesay.ChooseByName(names, match, GOBCowNames, MetadataRoot)
t.Mark("find/read metadata")

pokesay.Print(args, subIdx, GenerateNames(metadata, args), final.Categories, GOBCowData)
pokesay.Print(args, subIdx, GenerateNames(metadata, args, final), final.Categories, GOBCowData)
t.Mark("print")

t.Stop()
Expand All @@ -227,7 +228,7 @@ func runPrintByCategory(args pokesay.Args) {
dir, _ := GOBCategories.ReadDir(dirPath)
metadata, final := pokesay.ChooseByCategory(args.Category, dir, GOBCategories, CategoryRoot, GOBCowNames, MetadataRoot)

pokesay.Print(args, final.EntryIndex, GenerateNames(metadata, args), final.Categories, GOBCowData)
pokesay.Print(args, final.EntryIndex, GenerateNames(metadata, args, final), final.Categories, GOBCowData)
t.Mark("print")

t.Stop()
Expand All @@ -247,7 +248,7 @@ func runPrintByNameAndCategory(args pokesay.Args) {
metadata, final := pokesay.ChooseByNameAndCategory(names, args.NameToken, GOBCowNames, MetadataRoot, args.Category)
t.Mark("find/read metadata")

pokesay.Print(args, final.EntryIndex, GenerateNames(metadata, args), final.Categories, GOBCowData)
pokesay.Print(args, final.EntryIndex, GenerateNames(metadata, args, final), final.Categories, GOBCowData)
t.Mark("print")

t.Stop()
Expand All @@ -270,7 +271,7 @@ func runPrintRandom(args pokesay.Args) {
final := metadata.Entries[pokesay.RandomInt(len(metadata.Entries))]
t.Mark("choose entry")

pokesay.Print(args, final.EntryIndex, GenerateNames(metadata, args), final.Categories, GOBCowData)
pokesay.Print(args, final.EntryIndex, GenerateNames(metadata, args, final), final.Categories, GOBCowData)
t.Mark("print")

t.Stop()
Expand Down

0 comments on commit 592b908

Please sign in to comment.