Skip to content

Commit 2b59514

Browse files
committed
fix: lint things
1 parent c72670b commit 2b59514

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

wallhaven/cli.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func Collection(cmd *cobra.Command, args []string) error {
121121
id := re.FindStringSubmatch(SelectedID)[1]
122122

123123
if all {
124-
for true {
124+
for {
125125
images, err := CollectionAPI(username, id, page)
126126
if err != nil {
127127
return err
@@ -236,7 +236,10 @@ func Preview(cmd *cobra.Command, args []string) error {
236236
url,
237237
)
238238
} else if path != "" {
239-
DLSave(url, &config.TempFolder)
239+
err := DLSave(url, &config.TempFolder)
240+
if err != nil {
241+
return err
242+
}
240243

241244
SplitUrl := strings.Split(url, "/")
242245
FileName := SplitUrl[len(SplitUrl)-1]

wallhaven/main.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"fmt"
45
"log"
56
"os"
67
"os/user"
@@ -52,19 +53,28 @@ func init() {
5253
return
5354
}
5455

55-
os.WriteFile(configPath, encodedData, os.ModePerm)
56+
if err := os.WriteFile(configPath, encodedData, os.ModePerm); err != nil {
57+
fmt.Print(err)
58+
os.Exit(1)
59+
}
60+
}
61+
62+
if err := os.MkdirAll(config.TempFolder, os.ModePerm); err != nil {
63+
fmt.Print(err)
64+
os.Exit(1)
5665
}
5766

58-
os.MkdirAll(config.TempFolder, os.ModePerm)
59-
os.MkdirAll(config.SaveFolder, os.ModePerm)
67+
if err := os.MkdirAll(config.SaveFolder, os.ModePerm); err != nil {
68+
fmt.Print(err)
69+
os.Exit(1)
70+
}
6071
} else {
6172
log.Fatalf("Your os isn't supported: %v", runtime.GOOS)
6273
return
6374
}
6475
}
6576

6677
var page int
67-
var editor string
6878
var all bool
6979

7080
func main() {
@@ -117,5 +127,8 @@ func main() {
117127

118128
rootCmd.AddCommand(searchCmd, downloadCmd, editCmd, collectionCmd, previewCmd)
119129

120-
rootCmd.Execute()
130+
if err := rootCmd.Execute(); err != nil {
131+
fmt.Print(err)
132+
os.Exit(1)
133+
}
121134
}

0 commit comments

Comments
 (0)