@@ -21,7 +21,6 @@ import (
2121 "github.com/rawnly/splash-cli/lib/blurhash"
2222 "github.com/rawnly/splash-cli/lib/keys"
2323 "github.com/rawnly/splash-cli/lib/terminal"
24- "github.com/rawnly/splash-cli/unsplash"
2524 "github.com/rawnly/splash-cli/unsplash/models"
2625 "github.com/sirupsen/logrus"
2726 "github.com/spf13/cobra"
@@ -32,7 +31,7 @@ type photoFlags struct {
3231 Day bool `json:"day" description:"Get a the photo of the day"`
3332 Orientation string `json:"orientation" default:"landscape" description:"Specifies the photo orientation"`
3433 Query string `json:"query" description:"Search for a photo"`
35- Id string `json:"id" description:"Get a photo by id"`
34+ ID string `json:"id" description:"Get a photo by id"`
3635 Save bool `json:"save" description:"Save the photo without setting it as wallpaper"`
3736 Scale string `json:"scale" default:"auto" description:"Set wallpaper scale"`
3837 IgnoreCache bool `json:"ignore-cache" default:"false" description:"Ignore cache and download image again"`
@@ -88,10 +87,10 @@ var rootCmd = &cobra.Command{
8887 var err error
8988
9089 ctx := cmd .Context ()
91- api := ctx . Value ( "api" ).(unsplash. Api )
90+ api := keys . GetAPIInstance ( ctx )
9291 analytics := keys .GetAnalyticsInstance (ctx )
9392
94- photoOfTheDayId := viper .GetString ("photo-of-the-day.id" )
93+ photoOfTheDayID := viper .GetString ("photo-of-the-day.id" )
9594
9695 ConnectionSpinnerSuffix := []string {" Connecting to Unsplash..." , "Failed to connect\n " , "✔ Connected" }
9796 DownloadSpinnerSuffix := []string {" Downloading photo..." , "Failed to download\n " , "✔ Downloaded" }
@@ -136,8 +135,8 @@ var rootCmd = &cobra.Command{
136135 if dayFlag {
137136 analytics .Capture ("photo_of_the_day" , nil )
138137
139- if photoOfTheDayId != "" && ! ignoreCacheFlag {
140- photo , err = api .GetPhoto (photoOfTheDayId )
138+ if photoOfTheDayID != "" && ! ignoreCacheFlag {
139+ photo , err = api .GetPhoto (photoOfTheDayID )
141140 } else {
142141 photo , err = api .GetPhotoOfTheDay ()
143142 if err != nil {
@@ -161,7 +160,7 @@ var rootCmd = &cobra.Command{
161160
162161 handleSpinnerError (err , connectionSpinner , cmd , ConnectionSpinnerSuffix [1 ])
163162 } else if idFlag != "" {
164- idFlag = lib .ParsePhotoIDFromUrl (idFlag )
163+ idFlag = lib .ParsePhotoIDFromURL (idFlag )
165164
166165 analytics .Capture ("photo_by_id" , map [string ]any {
167166 "photo_id" : idFlag ,
@@ -172,7 +171,8 @@ var rootCmd = &cobra.Command{
172171 } else {
173172 analytics .Capture ("random_photo" , nil )
174173
175- photos , err := api .GetRandomPhoto (models.RandomPhotoParams {
174+ var photos []models.Photo
175+ photos , err = api .GetRandomPhoto (models.RandomPhotoParams {
176176 Orientation : orientationFlag ,
177177 Query : queryFlag ,
178178 Count : 1 ,
@@ -199,7 +199,8 @@ var rootCmd = &cobra.Command{
199199 downloadFolder := viper .GetString ("download_dir" )
200200
201201 if downloadFolder == "" {
202- folder , err := lib .HomePath ("Pictures" )
202+ var folder string
203+ folder , err = lib .HomePath ("Pictures" )
203204 handleSpinnerError (err , downloadSpinner , cmd , DownloadSpinnerSuffix [1 ])
204205
205206 downloadFolder = folder
@@ -213,6 +214,11 @@ var rootCmd = &cobra.Command{
213214
214215 var location string
215216
217+ // debug printing
218+ fmt .Println ("Download location:" , downloadLocation )
219+ fmt .Println ("Ignore cache:" , ignoreCacheFlag )
220+ fmt .Println ("File exists:" , lib .FileExists (downloadLocation ))
221+
216222 if lib .FileExists (downloadLocation ) && ! ignoreCacheFlag {
217223 location = downloadLocation
218224
@@ -235,10 +241,11 @@ var rootCmd = &cobra.Command{
235241 fmt .Println ("Would you like to set it from the URL?" )
236242 fmt .Println ("" )
237243
238- _ , key , err := keyboard .GetSingleKey ()
244+ var key keyboard.Key
245+ _ , key , err = keyboard .GetSingleKey ()
239246 if err != nil {
240- evtId := sentry .CaptureException (err )
241- logrus .WithField ("event_id" , evtId ).Fatal (err )
247+ eventID := sentry .CaptureException (err )
248+ logrus .WithField ("event_id" , eventID ).Fatal (err )
242249 }
243250
244251 switch key {
0 commit comments