Skip to content

Commit

Permalink
added safe check
Browse files Browse the repository at this point in the history
  • Loading branch information
coderj001 committed Feb 20, 2023
1 parent aa69105 commit 6f8efa5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,11 @@ for repositories. [Dependabot][dependabot-link] will implicitly create the
`dependencies` label with the first pull request raised by it.

The remaining labels can be created as needed!
<br>
<br>

## TODO:
1. Limit the number of go worker should be user input
2. Page input should be a range of pages (need to rewrite apifech function & others)
3. Resolution shlould be fzf style multi-select (will try to apply on other fields)
:
:
5 changes: 5 additions & 0 deletions src/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"log"
"os"

"github.com/spf13/cobra"
Expand All @@ -27,6 +28,10 @@ var rootCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
url := app.GetFullURL(page, categories, purity, sorting, colors, query)
searchList, _ := app.FetchAPI(url)
if len(searchList.Data) <= 0 {
log.Panicln("Unable to fetch data form api url: ", url)
os.Exit(1)
}
app.Downloader(&searchList, dir)
},
}
Expand Down
3 changes: 1 addition & 2 deletions src/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ func init() {
viper.SetConfigFile(fmt.Sprintf("%s/.go-wallhaven", os.Getenv("HOME")))
viper.SetConfigType("json")
if err := viper.ReadInConfig(); err != nil {
log.Fatalf("Error reading config file, %s", err)
os.Exit(1)
log.Printf("Error reading config file, %s\n", err)
}
apikey = viper.GetString("API_KEY")
dir = viper.GetString("DIR")
Expand Down

0 comments on commit 6f8efa5

Please sign in to comment.