Skip to content

Commit 6f8efa5

Browse files
committed
added safe check
1 parent aa69105 commit 6f8efa5

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,11 @@ for repositories. [Dependabot][dependabot-link] will implicitly create the
310310
`dependencies` label with the first pull request raised by it.
311311

312312
The remaining labels can be created as needed!
313-
<br>
313+
<br>
314+
315+
## TODO:
316+
1. Limit the number of go worker should be user input
317+
2. Page input should be a range of pages (need to rewrite apifech function & others)
318+
3. Resolution shlould be fzf style multi-select (will try to apply on other fields)
319+
:
320+
:

src/cmd/root.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cmd
22

33
import (
44
"fmt"
5+
"log"
56
"os"
67

78
"github.com/spf13/cobra"
@@ -27,6 +28,10 @@ var rootCmd = &cobra.Command{
2728
Run: func(cmd *cobra.Command, args []string) {
2829
url := app.GetFullURL(page, categories, purity, sorting, colors, query)
2930
searchList, _ := app.FetchAPI(url)
31+
if len(searchList.Data) <= 0 {
32+
log.Panicln("Unable to fetch data form api url: ", url)
33+
os.Exit(1)
34+
}
3035
app.Downloader(&searchList, dir)
3136
},
3237
}

src/config.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ func init() {
104104
viper.SetConfigFile(fmt.Sprintf("%s/.go-wallhaven", os.Getenv("HOME")))
105105
viper.SetConfigType("json")
106106
if err := viper.ReadInConfig(); err != nil {
107-
log.Fatalf("Error reading config file, %s", err)
108-
os.Exit(1)
107+
log.Printf("Error reading config file, %s\n", err)
109108
}
110109
apikey = viper.GetString("API_KEY")
111110
dir = viper.GetString("DIR")

0 commit comments

Comments
 (0)