Skip to content

Commit

Permalink
Minor mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
Wraient committed Oct 28, 2024
1 parent 4bc130d commit d6ac226
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
29 changes: 17 additions & 12 deletions cmd/curd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,6 @@ func main() {
}

if *rofiSelection {
// Define a slice of file names to check and download
filesToCheck := []string{
"selectanimepreview.rasi",
"selectanime.rasi",
"userinput.rasi",
}

// Call the function to check and download files
if err := internal.CheckAndDownloadFiles(userCurdConfig.StoragePath, filesToCheck); err != nil {
internal.CurdOut(fmt.Sprintf("Error checking and downloading files: %v\n", err))
internal.ExitCurd(err)
}
userCurdConfig.RofiSelection = true
}

Expand Down Expand Up @@ -139,6 +127,23 @@ func main() {
internal.ChangeToken(&userCurdConfig, &user)
}

if userCurdConfig.RofiSelection {
// Define a slice of file names to check and download
filesToCheck := []string{
"selectanimepreview.rasi",
"selectanime.rasi",
"userinput.rasi",
}

// Call the function to check and download files
err := internal.CheckAndDownloadFiles(os.ExpandEnv(userCurdConfig.StoragePath), filesToCheck)
if err != nil {
internal.Log(fmt.Sprintf("Error checking and downloading files: %v\n", err), logFile)
internal.CurdOut(fmt.Sprintf("Error checking and downloading files: %v\n", err))
internal.ExitCurd(err)
}
}

// Load animes in database
databaseFile := filepath.Join(os.ExpandEnv(userCurdConfig.StoragePath), "curd_history.txt")
databaseAnimes := internal.LocalGetAllAnime(databaseFile)
Expand Down
2 changes: 1 addition & 1 deletion internal/curd.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ func CheckAndDownloadFiles(storagePath string, filesToCheck []string) error {

// Check each file
for _, fileName := range filesToCheck {
filePath := filepath.Join(storagePath, fileName)
filePath := filepath.Join(os.ExpandEnv(storagePath), fileName)

// Skip if file already exists
if _, err := os.Stat(filePath); err == nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/rofi.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func GetUserInputFromRofi(message string) (string, error) {
userCurdConfig.StoragePath = os.ExpandEnv("${HOME}/.local/share/curd")
}
// Create the Rofi command
cmd := exec.Command("rofi", "-dmenu", "-theme", filepath.Join(userCurdConfig.StoragePath, "userinput.rasi"), "-p", "Input", "-mesg", message)
cmd := exec.Command("rofi", "-dmenu", "-theme", filepath.Join(os.ExpandEnv(userCurdConfig.StoragePath), "userinput.rasi"), "-p", "Input", "-mesg", message)

// Set up pipes for output
var out bytes.Buffer
Expand Down
4 changes: 2 additions & 2 deletions internal/selection_menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func DynamicSelectPreview(options map[string]RofiSelectPreview, addnewoption boo
rofiInput.WriteString("Quit\n")

// Get the absolute path to the rasi config
configPath := filepath.Join(userCurdConfig.StoragePath, "selectanimepreview.rasi")
configPath := filepath.Join(os.ExpandEnv(userCurdConfig.StoragePath), "selectanimepreview.rasi")

// Create the command with explicit arguments
args := []string{
Expand Down Expand Up @@ -353,7 +353,7 @@ func RofiSelect(options map[string]string, addanimeopt bool) (SelectionOption, e
optionsString := strings.Join(optionsList, "\n")

// Prepare the Rofi command
cmd := exec.Command("rofi", "-dmenu", "-theme", filepath.Join(userCurdConfig.StoragePath, "selectanime.rasi"), "-i", "-p", "Select an anime")
cmd := exec.Command("rofi", "-dmenu", "-theme", filepath.Join(os.ExpandEnv(userCurdConfig.StoragePath), "selectanime.rasi"), "-i", "-p", "Select an anime")

// Set up pipes for input and output
cmd.Stdin = strings.NewReader(optionsString)
Expand Down

0 comments on commit d6ac226

Please sign in to comment.