|
1 | 1 | package cmd |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "fmt" |
5 | | - "strconv" |
6 | | - |
7 | | - "github.com/CosmicPredator/chibi/internal" |
8 | | - "github.com/charmbracelet/lipgloss" |
| 4 | + "github.com/CosmicPredator/chibi/internal/ui" |
| 5 | + "github.com/CosmicPredator/chibi/internal/viewmodel" |
9 | 6 | "github.com/spf13/cobra" |
10 | 7 | ) |
11 | 8 |
|
12 | | -func getUserProfile() { |
13 | | - CheckIfTokenExists() |
14 | | - profile := internal.NewProfile() |
15 | | - err := profile.Get() |
16 | | - if err != nil { |
17 | | - ErrorMessage(err.Error()) |
18 | | - } |
| 9 | +// func getUserProfile() { |
| 10 | +// CheckIfTokenExists() |
| 11 | +// profile := internal.NewProfile() |
| 12 | +// err := profile.Get() |
| 13 | +// if err != nil { |
| 14 | +// ErrorMessage(err.Error()) |
| 15 | +// } |
19 | 16 |
|
20 | | - keyStyle := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("#FF79C6")) |
21 | | - valueStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#8BE9FD")) |
| 17 | +// keyStyle := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("#FF79C6")) |
| 18 | +// valueStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#8BE9FD")) |
22 | 19 |
|
23 | | - fmt.Printf("%-20s : %s\n", keyStyle.Render("ID"), valueStyle.Render(strconv.Itoa(profile.Data.Viewer.Id))) |
24 | | - fmt.Printf("%-20s : %s\n", keyStyle.Render("Name"), valueStyle.Render(profile.Data.Viewer.Name)) |
25 | | - fmt.Printf("%-20s : %s\n", keyStyle.Render("Total Anime"), valueStyle.Render(strconv.Itoa(profile.Data.Viewer.Statistics.Anime.Count))) |
26 | | - fmt.Printf("%-20s : %s\n", keyStyle.Render("Total Manga"), valueStyle.Render(strconv.Itoa(profile.Data.Viewer.Statistics.Manga.Count))) |
27 | | - fmt.Printf("%-20s : %s\n", keyStyle.Render("Total Days Watched"), valueStyle.Render(fmt.Sprintf("%.2f", float32(profile.Data.Viewer.Statistics.Anime.MinutesWatched)/1440))) |
28 | | - fmt.Printf("%-20s : %s\n", keyStyle.Render("Total Chapters Read"), valueStyle.Render(strconv.Itoa(profile.Data.Viewer.Statistics.Manga.ChaptersRead))) |
29 | | - fmt.Printf("%-20s : %s\n", keyStyle.Render("URL"), valueStyle.Render(profile.Data.Viewer.SiteUrl)) |
| 20 | +// fmt.Printf("%-20s : %s\n", keyStyle.Render("ID"), valueStyle.Render(strconv.Itoa(profile.Data.Viewer.Id))) |
| 21 | +// fmt.Printf("%-20s : %s\n", keyStyle.Render("Name"), valueStyle.Render(profile.Data.Viewer.Name)) |
| 22 | +// fmt.Printf("%-20s : %s\n", keyStyle.Render("Total Anime"), valueStyle.Render(strconv.Itoa(profile.Data.Viewer.Statistics.Anime.Count))) |
| 23 | +// fmt.Printf("%-20s : %s\n", keyStyle.Render("Total Manga"), valueStyle.Render(strconv.Itoa(profile.Data.Viewer.Statistics.Manga.Count))) |
| 24 | +// fmt.Printf("%-20s : %s\n", keyStyle.Render("Total Days Watched"), valueStyle.Render(fmt.Sprintf("%.2f", float32(profile.Data.Viewer.Statistics.Anime.MinutesWatched)/1440))) |
| 25 | +// fmt.Printf("%-20s : %s\n", keyStyle.Render("Total Chapters Read"), valueStyle.Render(strconv.Itoa(profile.Data.Viewer.Statistics.Manga.ChaptersRead))) |
| 26 | +// fmt.Printf("%-20s : %s\n", keyStyle.Render("URL"), valueStyle.Render(profile.Data.Viewer.SiteUrl)) |
| 27 | +// } |
| 28 | + |
| 29 | +func handleProfile(cmd *cobra.Command, args []string) { |
| 30 | + err := viewmodel.HandleProfile() |
| 31 | + if err != nil { |
| 32 | + ui.ErrorText(err) |
| 33 | + } |
30 | 34 | } |
31 | 35 |
|
32 | 36 | var profileCmd = &cobra.Command{ |
33 | 37 | Use: "profile", |
34 | 38 | Short: "Get's your AniList profile (requires login)", |
35 | | - Run: func(cmd *cobra.Command, args []string) { |
36 | | - getUserProfile() |
37 | | - }, |
| 39 | + Run: handleProfile, |
38 | 40 | } |
0 commit comments