Commit d6ac226ed0

d6ac226ed07f2ba9d9e26a5eef47e64dd748e4cb

parent: 4bc130de1b

Unsigned

Wraient <wraient.911@gmail.com> · 2024-10-28 08:46 UTC

Minor mistakes

Layout: unified · split

cmd/curd/main.go +17 −12
@@ -99,18 +99,6 @@ func main() {
9999 }
100100
101101 if *rofiSelection {
102 // Define a slice of file names to check and download
103 filesToCheck := []string{
104 "selectanimepreview.rasi",
105 "selectanime.rasi",
106 "userinput.rasi",
107 }
108
109 // Call the function to check and download files
110 if err := internal.CheckAndDownloadFiles(userCurdConfig.StoragePath, filesToCheck); err != nil {
111 internal.CurdOut(fmt.Sprintf("Error checking and downloading files: %v\n", err))
112 internal.ExitCurd(err)
113 }
114102 userCurdConfig.RofiSelection = true
115103 }
116104
@@ -139,6 +127,23 @@ func main() {
139127 internal.ChangeToken(&userCurdConfig, &user)
140128 }
141129
130 if userCurdConfig.RofiSelection {
131 // Define a slice of file names to check and download
132 filesToCheck := []string{
133 "selectanimepreview.rasi",
134 "selectanime.rasi",
135 "userinput.rasi",
136 }
137
138 // Call the function to check and download files
139 err := internal.CheckAndDownloadFiles(os.ExpandEnv(userCurdConfig.StoragePath), filesToCheck)
140 if err != nil {
141 internal.Log(fmt.Sprintf("Error checking and downloading files: %v\n", err), logFile)
142 internal.CurdOut(fmt.Sprintf("Error checking and downloading files: %v\n", err))
143 internal.ExitCurd(err)
144 }
145 }
146
142147 // Load animes in database
143148 databaseFile := filepath.Join(os.ExpandEnv(userCurdConfig.StoragePath), "curd_history.txt")
144149 databaseAnimes := internal.LocalGetAllAnime(databaseFile)
internal/curd.go +1 −1
@@ -600,7 +600,7 @@ func CheckAndDownloadFiles(storagePath string, filesToCheck []string) error {
600600
601601 // Check each file
602602 for _, fileName := range filesToCheck {
603 filePath := filepath.Join(storagePath, fileName)
603 filePath := filepath.Join(os.ExpandEnv(storagePath), fileName)
604604
605605 // Skip if file already exists
606606 if _, err := os.Stat(filePath); err == nil {
internal/rofi.go +1 −1
@@ -42,7 +42,7 @@ func GetUserInputFromRofi(message string) (string, error) {
4242 userCurdConfig.StoragePath = os.ExpandEnv("${HOME}/.local/share/curd")
4343 }
4444 // Create the Rofi command
45 cmd := exec.Command("rofi", "-dmenu", "-theme", filepath.Join(userCurdConfig.StoragePath, "userinput.rasi"), "-p", "Input", "-mesg", message)
45 cmd := exec.Command("rofi", "-dmenu", "-theme", filepath.Join(os.ExpandEnv(userCurdConfig.StoragePath), "userinput.rasi"), "-p", "Input", "-mesg", message)
4646
4747 // Set up pipes for output
4848 var out bytes.Buffer
internal/selection_menu.go +2 −2
@@ -207,7 +207,7 @@ func DynamicSelectPreview(options map[string]RofiSelectPreview, addnewoption boo
207207 rofiInput.WriteString("Quit\n")
208208
209209 // Get the absolute path to the rasi config
210 configPath := filepath.Join(userCurdConfig.StoragePath, "selectanimepreview.rasi")
210 configPath := filepath.Join(os.ExpandEnv(userCurdConfig.StoragePath), "selectanimepreview.rasi")
211211
212212 // Create the command with explicit arguments
213213 args := []string{
@@ -353,7 +353,7 @@ func RofiSelect(options map[string]string, addanimeopt bool) (SelectionOption, e
353353 optionsString := strings.Join(optionsList, "\n")
354354
355355 // Prepare the Rofi command
356 cmd := exec.Command("rofi", "-dmenu", "-theme", filepath.Join(userCurdConfig.StoragePath, "selectanime.rasi"), "-i", "-p", "Select an anime")
356 cmd := exec.Command("rofi", "-dmenu", "-theme", filepath.Join(os.ExpandEnv(userCurdConfig.StoragePath), "selectanime.rasi"), "-i", "-p", "Select an anime")
357357
358358 // Set up pipes for input and output
359359 cmd.Stdin = strings.NewReader(optionsString)