File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ func favouriteEpisode(episodeNumber int) {
115
115
}
116
116
}
117
117
118
- func listFavouriteEpisode () {
118
+ func listFavouriteEpisodes () {
119
119
file , err := os .Open ("favourites.json" )
120
120
if err != nil {
121
121
if errors .Is (err , os .ErrNotExist ) {
@@ -134,10 +134,15 @@ func listFavouriteEpisode() {
134
134
return
135
135
}
136
136
137
- fmt .Println ("Your Favourite Episodes" )
138
- for key , value := range favouriteEpisodes {
139
- fmt .Printf ("Episode %d : %s \n " , key , value )
137
+ table := tablewriter .NewWriter (os .Stdout )
138
+ table .SetHeader ([]string {"Episode" , "Number" })
139
+ table .SetAutoWrapText (false )
140
+
141
+ for i , title := range favouriteEpisodes {
142
+ table .Append ([]string {title , fmt .Sprintf ("%d" , i + 1 )})
140
143
}
144
+
145
+ table .Render ()
141
146
}
142
147
143
148
var favouriteEpisodesJson = make (map [int ]string )
@@ -242,7 +247,7 @@ func main() {
242
247
listEpisodes (episodesTitles )
243
248
}
244
249
if * listFavourites {
245
- listFavouriteEpisode ()
250
+ listFavouriteEpisodes ()
246
251
return
247
252
}
248
253
if * addFavouriteEpisode != 0 {
You can’t perform that action at this time.
0 commit comments