func updateLogoFromUnsplashFile()

in cobra/controller/render.go [133:177]


func updateLogoFromUnsplashFile() bool {
	if helper.FileExists("unsplash.yaml") {
		configPath, _ := os.Getwd()
		configName := "unsplash"
		configType := "yaml"

		var response model.UnsplashRandomPhotoResponse

		v, err := aid.ReadConfigAsViper(configPath, configName, configType)
		if err != nil {
			logrus.Errorf("unable to read unsplash.yaml as viper object\n%v", err)
			return false
		}

		err = v.Unmarshal(&response)
		if err != nil {
			logrus.Errorf("unable to unmarshall unsplash.yaml as unsplash response\n%v", err)
			return false
		}

		err = helper.DownloadFile(response.Urls.Regular, "clencli", "logo.jpeg")
		if err != nil {
			logrus.Errorf("unable to download photo\n%v", err)
			return false
		}

		response.Urls.Regular = "clencli/logo.jpeg"

		readMe, err := dao.GetReadMe()
		if err != nil {
			logrus.Errorf("Unable to get local readme config\n%v", err)
			return false
		}

		err = aid.UpdateReadMeLogoURL(readMe, response)
		if err != nil {
			logrus.Errorf("unable to update logo URL\n%s", err)
			return false
		}

		return true
	}

	return false
}