Skip to content

Commit

Permalink
chore: resolve golangci-lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
noornee committed Dec 25, 2024
1 parent b96b12c commit c747125
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 128 deletions.
9 changes: 5 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@ package main
import (
"flag"
"fmt"
kaizen "github.com/serene-brew/Kaizen/src"
"os"
"os/exec"

kaizen "github.com/serene-brew/Kaizen/src"
)

// Main entrypoint for the application
func main() {
//perform auto-heal check before starting kaizen
// perform auto-heal check before starting kaizen
kaizen.AutoHeal()

//check whether MPV-player is installed or not
// check whether MPV-player is installed or not
_, err := exec.LookPath("mpv")
if err != nil {
fmt.Println("[!] Please install MPV-player using your package manager before running kaizen")
os.Exit(1)
}

//kaizen CLI flags
// kaizen CLI flags
uninstalFlag := flag.Bool("uninstall", false, "Run the uninstaller script")
updateFlag := flag.Bool("update", false, "Run the update script")
versionFlag := flag.Bool("v", false, "views version information")
Expand Down
4 changes: 2 additions & 2 deletions src/APIcore.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ If an error occurs at any point, it is returned along with an empty string.
resp -> string [Stream link]
*/
func getStreamLink(id string, espisodeType string, episodeNumber string) (string, error) {
apiUrl := "https://heavenscape.vercel.app/api/anime/search/" + id + "/" + espisodeType + "/" + episodeNumber
apiURL := "https://heavenscape.vercel.app/api/anime/search/" + id + "/" + espisodeType + "/" + episodeNumber

resp, err := http.Get(apiUrl)
resp, err := http.Get(apiURL)
if err != nil {
return "", err
}
Expand Down
66 changes: 33 additions & 33 deletions src/WatchAnime.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,36 @@ var (
keys = newKeyMap()
)

type focus int
type Tab1Model struct {
focus focus
styles Tab1styles
inputM textinput.Model
listOne list.Model
listTwo list.Model
table table.Model
spinner spinner.Model

loading bool
loadingMSG string
data [][]interface{}

width int
height int

animeID string
animeName string
subEpisodeNumber int
dubEpisodeNumber int
subSelectedNum string
dubSelectedNum string
episodeType string
streamLink string
availableSubEpisodes []string
availableDubEpisodes []string
}
type (
focus int
Tab1Model struct {
focus focus
styles Tab1styles
inputM textinput.Model
listOne list.Model
listTwo list.Model
table table.Model
spinner spinner.Model

loading bool
loadingMSG string
data [][]interface{}

width int
height int //nolint:unused

animeID string
animeName string
subEpisodeNumber int
dubEpisodeNumber int
subSelectedNum string
dubSelectedNum string
episodeType string
streamLink string
availableSubEpisodes []string
availableDubEpisodes []string
}
)

type item struct {
title string
Expand Down Expand Up @@ -86,7 +88,7 @@ func NewTab1Model() Tab1Model {

spin := spinner.New()
spin.Spinner = spinner.Dot
spin.Style = lipgloss.NewStyle().Foreground(lipgloss.Color(conf.Tab1_SpinnerColor))
spin.Style = lipgloss.NewStyle().Foreground(lipgloss.Color(conf.Tab1SpinnerColor))

columns := []table.Column{
{Title: "", Width: 10},
Expand Down Expand Up @@ -238,7 +240,6 @@ func (m Tab1Model) Update(msg tea.Msg) (Tab1Model, tea.Cmd) {
m.styles.list2Border = m.styles.list2Border.BorderForeground(lipgloss.Color(m.styles.inactiveColor))
m.styles.tableBorder = m.styles.tableBorder.BorderForeground(lipgloss.Color(m.styles.inactiveColor))
}

} else if m.focus == listOneFocus {
m.streamSubAnime()
m.styles.inputBorder = m.styles.inputBorder.BorderForeground(lipgloss.Color(m.styles.inactiveColor))
Expand All @@ -254,7 +255,6 @@ func (m Tab1Model) Update(msg tea.Msg) (Tab1Model, tea.Cmd) {
}
return m, nil
}

}

// Update the active component based on focus, and return a batch of commands
Expand Down Expand Up @@ -314,15 +314,15 @@ func (m Tab1Model) View() string {
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣴⣿⡿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣿⣿⣿⣶⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣾⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⠟⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠛⠛⠉⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣿⣿⣶⣶⣶⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣿⡿⠛⠛⠛⠛⠉⠉⠉⠉⠉⠉⠉`
asciiS := lipgloss.NewStyle().Foreground(lipgloss.Color(conf.Tab1_kaizen_AscciArtColor))
asciiS := lipgloss.NewStyle().Foreground(lipgloss.Color(conf.Tab1KaizenAscciArtColor))
if m.loading {
return lipgloss.JoinVertical(
lipgloss.Top,
inputS,
lipgloss.JoinHorizontal(
lipgloss.Top,
m.spinner.View(),
lipgloss.NewStyle().Foreground(lipgloss.Color(conf.Tab1_SpinnerMsgColor)).Render(m.loadingMSG)),
lipgloss.NewStyle().Foreground(lipgloss.Color(conf.Tab1SpinnerMsgColor)).Render(m.loadingMSG)),
tableS,
lipgloss.JoinHorizontal(
lipgloss.Top,
Expand Down
44 changes: 22 additions & 22 deletions src/about.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (m Tab2Model) Init() tea.Cmd {
return nil
}

func (m Tab2Model) Update(msg tea.Msg) (Tab2Model, tea.Cmd) {
func (m Tab2Model) Update(_ tea.Msg) (Tab2Model, tea.Cmd) {
// Tab2 doesn't react to input, just static content
return m, nil
}
Expand All @@ -41,7 +41,7 @@ func (m Tab2Model) View() string {

link := lipgloss.NewStyle().Foreground(lipgloss.Color("#43BF6D")).Render

ui := lipgloss.JoinVertical(lipgloss.Center, lipgloss.NewStyle().Foreground(lipgloss.Color(conf.defaultActiveTab_dark)).Render("kaizen"))
ui := lipgloss.JoinVertical(lipgloss.Center, lipgloss.NewStyle().Foreground(lipgloss.Color(conf.defaultActiveTabDark)).Render("kaizen"))

desc := `Ever feel like your terminal was missing something?
Like, sure, it can handle your code, your servers, and maybe a cheeky game of Snake.
Expand All @@ -60,28 +60,28 @@ Enjoy your experience, and let Kaizen be your companion on your journey into the
lipgloss.WithWhitespaceForeground(lipgloss.Color("#383838")),
)

mintRaven_github := link("https://github.com/mintRaven-05")
riserSama_github := link("https://github.com/ImonChakraborty")
sereneBrew_github := link("https://github.com/serene-brew")
dev_community := link("https://dev.to/serene-brew")
mintRavenGithub := link("https://github.com/mintRaven-05")
riserSamaGithub := link("https://github.com/ImonChakraborty")
sereneBrewGithub := link("https://github.com/serene-brew")
devCommunity := link("https://dev.to/serene-brew")

short_title1 := "Want to see more from us? Follow us on our socials.\n"
socials := "•" + mintRaven_github + "\n•" + riserSama_github + "\n"
socials_end := "(github is the only social life we have)\n"
socialsText := short_title1 + socials + socials_end
shortTitle1 := "Want to see more from us? Follow us on our socials.\n"
socials := "•" + mintRavenGithub + "\n•" + riserSamaGithub + "\n"
socialsEnd := "(github is the only social life we have)\n"
socialsText := shortTitle1 + socials + socialsEnd

short_title2 := "Check out the latest project from\n"
github := "•" + sereneBrew_github + "\n"
github_end := "Found a bug? Report at the project repository.\n\n"
serene_brew := short_title2 + github + github_end
shortTitle2 := "Check out the latest project from\n"
github := "•" + sereneBrewGithub + "\n"
githubEnd := "Found a bug? Report at the project repository.\n\n"
sereneBrew := shortTitle2 + github + githubEnd

short_title3 := "keep up with our latest posts and news at\n"
dev := "•" + dev_community + "\n"
dev_end := "(dev.to is another social life we have for now)\n\n"
dev_text := short_title3 + dev + dev_end
shortTitle3 := "keep up with our latest posts and news at\n"
dev := "•" + devCommunity + "\n"
devEnd := "(dev.to is another social life we have for now)\n\n"
devText := shortTitle3 + dev + devEnd

email := link("\t serene.brew.git@gmail.com")
email_text := "\t ~developed by mintRaven & RiserSama\n" + email
emailText := "\t ~developed by mintRaven & RiserSama\n" + email

return lipgloss.JoinVertical(
lipgloss.Top,
Expand All @@ -94,7 +94,7 @@ Enjoy your experience, and let Kaizen be your companion on your journey into the
LinksStyle.Render(socialsText),
lipgloss.JoinVertical(
lipgloss.Top,
LinksStyle.Render(serene_brew),
FooterStyle.Render(email_text)),
LinksStyle.Render(dev_text)))
LinksStyle.Render(sereneBrew),
FooterStyle.Render(emailText)),
LinksStyle.Render(devText)))
}
3 changes: 2 additions & 1 deletion src/appState_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package src

import (
tea "github.com/charmbracelet/bubbletea"
"testing"

tea "github.com/charmbracelet/bubbletea"
)

func TestAppStateSimulation(t *testing.T) {
Expand Down
89 changes: 45 additions & 44 deletions src/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,33 @@ package src

import (
"fmt"
"github.com/spf13/viper"
"os"
"os/exec"
"path/filepath"
"time"

"github.com/spf13/viper"
)

/* Config struct defines the color configuration for different elements of the application.
* It includes attributes for foreground, unfocused states, active tabs, and specific settings
* for Tab1 such as focus state, table selection, spinner, and ASCII art colors.*/

type Config struct {
defaultForeground_light string
defaultForeground_dark string
defaultUnfocused_light string
defaultUnfocused_dark string
defaultActiveTab_light string
defaultActiveTab_dark string

Tab1_FocusActive string
Tab1_FocusInactive string
Tab1_TableSelectedBackground string
Tab1_TableSelectedForeground string
Tab1_SpinnerColor string
Tab1_SpinnerMsgColor string
Tab1_kaizen_AscciArtColor string
defaultForegroundLight string
defaultForegroundDark string
defaultUnfocusedLight string
defaultUnfocusedDark string
defaultActiveTabLight string
defaultActiveTabDark string

Tab1FocusActive string
Tab1FocusInactive string
Tab1TableSelectedBackground string
Tab1TableSelectedForeground string
Tab1SpinnerColor string
Tab1SpinnerMsgColor string
Tab1KaizenAscciArtColor string
}

/* LoadConfig function initializes the Config struct by reading values from a YAML configuration file.
Expand Down Expand Up @@ -69,35 +70,35 @@ func LoadConfig() Config {

var conf Config

defaultForeground_dark := viper.GetString("DefaultForeground.dark")
defaultForeground_light := viper.GetString("DefaultForeground.light")
defaultUnfocused_light := viper.GetString("DefaultUnfocused.light")
defaultUnfocused_dark := viper.GetString("DefaultUnfocused.dark")
defaultActiveTab_light := viper.GetString("DefaultActiveTab.light")
defaultActiveTab_dark := viper.GetString("DefaultActiveTab.dark")

Tab1_FocusActive := viper.GetString("Tab1.focus.active")
Tab1_FocusInactive := viper.GetString("Tab1.focus.inactive")
Tab1_TableSelectedForeground := viper.GetString("Tab1.table.selected.foreground")
Tab1_TableSelectedBackground := viper.GetString("Tab1.table.selected.background")
Tab1_SpinnerColor := viper.GetString("Tab1.spinner.color")
Tab1_SpinnerMsgColor := viper.GetString("Tab1.spinner.msg.color")
Tab1_kaizen_AscciArtColor := viper.GetString("Tab1.ASCII Art.color")

conf.defaultUnfocused_dark = defaultUnfocused_dark
conf.defaultUnfocused_light = defaultUnfocused_light
conf.defaultForeground_light = defaultForeground_light
conf.defaultForeground_dark = defaultForeground_dark
conf.defaultActiveTab_light = defaultActiveTab_light
conf.defaultActiveTab_dark = defaultActiveTab_dark

conf.Tab1_FocusActive = Tab1_FocusActive
conf.Tab1_FocusInactive = Tab1_FocusInactive
conf.Tab1_TableSelectedForeground = Tab1_TableSelectedForeground
conf.Tab1_TableSelectedBackground = Tab1_TableSelectedBackground
conf.Tab1_SpinnerColor = Tab1_SpinnerColor
conf.Tab1_SpinnerMsgColor = Tab1_SpinnerMsgColor
conf.Tab1_kaizen_AscciArtColor = Tab1_kaizen_AscciArtColor
defaultForegroundDark := viper.GetString("DefaultForeground.dark")
defaultForegroundLight := viper.GetString("DefaultForeground.light")
defaultUnfocusedLight := viper.GetString("DefaultUnfocused.light")
defaultUnfocusedDark := viper.GetString("DefaultUnfocused.dark")
defaultActiveTabLight := viper.GetString("DefaultActiveTab.light")
defaultActiveTabDark := viper.GetString("DefaultActiveTab.dark")

Tab1FocusActive := viper.GetString("Tab1.focus.active")
Tab1FocusInactive := viper.GetString("Tab1.focus.inactive")
Tab1TableSelectedForeground := viper.GetString("Tab1.table.selected.foreground")
Tab1TableSelectedBackground := viper.GetString("Tab1.table.selected.background")
Tab1SpinnerColor := viper.GetString("Tab1.spinner.color")
Tab1SpinnerMsgColor := viper.GetString("Tab1.spinner.msg.color")
Tab1KaizenAscciArtColor := viper.GetString("Tab1.ASCII Art.color")

conf.defaultUnfocusedDark = defaultUnfocusedDark
conf.defaultUnfocusedLight = defaultUnfocusedLight
conf.defaultForegroundLight = defaultForegroundLight
conf.defaultForegroundDark = defaultForegroundDark
conf.defaultActiveTabLight = defaultActiveTabLight
conf.defaultActiveTabDark = defaultActiveTabDark

conf.Tab1FocusActive = Tab1FocusActive
conf.Tab1FocusInactive = Tab1FocusInactive
conf.Tab1TableSelectedForeground = Tab1TableSelectedForeground
conf.Tab1TableSelectedBackground = Tab1TableSelectedBackground
conf.Tab1SpinnerColor = Tab1SpinnerColor
conf.Tab1SpinnerMsgColor = Tab1SpinnerMsgColor
conf.Tab1KaizenAscciArtColor = Tab1KaizenAscciArtColor

return conf
}
5 changes: 3 additions & 2 deletions src/mainModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package src

import (
"fmt"
"strings"

"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
gloss "github.com/charmbracelet/lipgloss"
"strings"
)

type AppState int
Expand Down Expand Up @@ -56,7 +57,7 @@ func (m MainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.currentScreen = AppScreen
}
case tea.KeyMsg:
//this switch handles when to show AppScreen and when to overlay the ErrorScreen over the AppScreen
// this switch handles when to show AppScreen and when to overlay the ErrorScreen over the AppScreen
switch m.currentScreen {
case AppScreen:
switch msg.String() {
Expand Down
3 changes: 1 addition & 2 deletions src/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ func AutoHeal() {
if err := uninstallModCmd.Run(); err != nil {
fmt.Fprintf(os.Stderr, "\033[0;33m [!] Error running shell code: %v \033[0m \n", err)
os.Exit(1)
}

}

time.Sleep(2 * time.Second)
fmt.Println("\033[0;32m [+] config.yaml configure at ~/.config/kaizen/ \033[0m")
Expand Down
Loading

0 comments on commit c747125

Please sign in to comment.