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() { |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | 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 | | } |
| 114 | 102 | userCurdConfig.RofiSelection = true |
| 115 | 103 | } |
| 116 | 104 | |
| @@ -139,6 +127,23 @@ func main() { |
| 139 | 127 | internal.ChangeToken(&userCurdConfig, &user) |
| 140 | 128 | } |
| 141 | 129 | |
| 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 | |
| 142 | 147 | // Load animes in database |
| 143 | 148 | databaseFile := filepath.Join(os.ExpandEnv(userCurdConfig.StoragePath), "curd_history.txt") |
| 144 | 149 | databaseAnimes := internal.LocalGetAllAnime(databaseFile) |
internal/curd.go
+1 −1
| @@ -600,7 +600,7 @@ func CheckAndDownloadFiles(storagePath string, filesToCheck []string) error { |
| 600 | 600 | |
| 601 | 601 | // Check each file |
| 602 | 602 | for _, fileName := range filesToCheck { |
| 603 | | filePath := filepath.Join(storagePath, fileName) |
| 603 | filePath := filepath.Join(os.ExpandEnv(storagePath), fileName) |
| 604 | 604 | |
| 605 | 605 | // Skip if file already exists |
| 606 | 606 | if _, err := os.Stat(filePath); err == nil { |
internal/rofi.go
+1 −1
| @@ -42,7 +42,7 @@ func GetUserInputFromRofi(message string) (string, error) { |
| 42 | 42 | userCurdConfig.StoragePath = os.ExpandEnv("${HOME}/.local/share/curd") |
| 43 | 43 | } |
| 44 | 44 | // 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) |
| 46 | 46 | |
| 47 | 47 | // Set up pipes for output |
| 48 | 48 | var out bytes.Buffer |
internal/selection_menu.go
+2 −2
| @@ -207,7 +207,7 @@ func DynamicSelectPreview(options map[string]RofiSelectPreview, addnewoption boo |
| 207 | 207 | rofiInput.WriteString("Quit\n") |
| 208 | 208 | |
| 209 | 209 | // 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") |
| 211 | 211 | |
| 212 | 212 | // Create the command with explicit arguments |
| 213 | 213 | args := []string{ |
| @@ -353,7 +353,7 @@ func RofiSelect(options map[string]string, addanimeopt bool) (SelectionOption, e |
| 353 | 353 | optionsString := strings.Join(optionsList, "\n") |
| 354 | 354 | |
| 355 | 355 | // 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") |
| 357 | 357 | |
| 358 | 358 | // Set up pipes for input and output |
| 359 | 359 | cmd.Stdin = strings.NewReader(optionsString) |