diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-07-06 23:23:01 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-07-06 23:23:01 +0530 |
commit | 83a39dbebed42b9bd779d86b4fcf30a0f5348d87 (patch) | |
tree | ced0a3cbcde63fdeb01e678191b3eee07e056ad4 /ui | |
parent | b5a8c767660fde8b73fee1ea0b261b28e35ccc62 (diff) |
added manga and nsfw results in list command
Diffstat (limited to 'ui')
-rw-r--r-- | ui/list.go (renamed from ui/animelist.go) | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/ui/animelist.go b/ui/list.go index c256666..f1eb10e 100644 --- a/ui/animelist.go +++ b/ui/list.go @@ -20,6 +20,7 @@ package ui import ( a "github.com/MikunoNaka/MAL2Go/v4/anime" + m "github.com/MikunoNaka/MAL2Go/v4/manga" "github.com/jedib0t/go-pretty/v6/table" "fmt" "os" @@ -52,3 +53,32 @@ func AnimeList(animes []a.Anime) { t.AppendFooter(table.Row{len(animes), "", "", ""}) t.Render() } + +func MangaList(mangas []m.Manga) { + t := table.NewWriter() + t.SetOutputMirror(os.Stdout) + + t.AppendHeader(table.Row{"#", "Title", "ID", "Score", "Type", "Status", "Chapters", "Volumes"}) + + for index, manga := range mangas { + status := manga.ListStatus.Status + score := manga.ListStatus.Score + + formattedStatus := GetColorCodeByStatus(status) + FormatStatus(status) + "\x1b[0m" + formattedScore := FormatScore(score) + + // TODO: format it + formattedMediaType := manga.MediaType + + chapterProgress := fmt.Sprintf("%d/%d", manga.ListStatus.ChaptersRead, manga.NumChapters) + volumeProgress := fmt.Sprintf("%d/%d", manga.ListStatus.VolumesRead, manga.NumVolumes) + + t.AppendRow([]interface{}{ + index + 1, manga.Title, manga.Id, formattedScore, formattedMediaType, formattedStatus, chapterProgress, volumeProgress, + }) + } + + t.AppendSeparator() + t.AppendFooter(table.Row{len(mangas), "", "", ""}) + t.Render() +} |