mirror of
				https://github.com/cheat/cheat.git
				synced 2025-11-04 07:45:28 +01:00 
			
		
		
		
	Fix Windows
This commit is contained in:
		@@ -2,7 +2,7 @@ package config
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"path"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
 | 
			
		||||
	"github.com/mitchellh/go-homedir"
 | 
			
		||||
)
 | 
			
		||||
@@ -33,20 +33,20 @@ func Paths(
 | 
			
		||||
 | 
			
		||||
		// don't include the `XDG_CONFIG_HOME` path if that envvar is not set
 | 
			
		||||
		if xdgpath, ok := envvars["XDG_CONFIG_HOME"]; ok {
 | 
			
		||||
			paths = append(paths, path.Join(xdgpath, "/cheat/conf.yml"))
 | 
			
		||||
			paths = append(paths, filepath.Join(xdgpath, "/cheat/conf.yml"))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		paths = append(paths, []string{
 | 
			
		||||
			path.Join(home, ".config/cheat/conf.yml"),
 | 
			
		||||
			path.Join(home, ".cheat/conf.yml"),
 | 
			
		||||
			filepath.Join(home, ".config/cheat/conf.yml"),
 | 
			
		||||
			filepath.Join(home, ".cheat/conf.yml"),
 | 
			
		||||
			"/etc/cheat/conf.yml",
 | 
			
		||||
		}...)
 | 
			
		||||
 | 
			
		||||
		return paths, nil
 | 
			
		||||
	case "windows":
 | 
			
		||||
		return []string{
 | 
			
		||||
			path.Join(envvars["APPDATA"], "/cheat/conf.yml"),
 | 
			
		||||
			path.Join(envvars["PROGRAMDATA"], "/cheat/conf.yml"),
 | 
			
		||||
			filepath.Join(envvars["APPDATA"], "/cheat/conf.yml"),
 | 
			
		||||
			filepath.Join(envvars["PROGRAMDATA"], "/cheat/conf.yml"),
 | 
			
		||||
		}, nil
 | 
			
		||||
	default:
 | 
			
		||||
		return []string{}, fmt.Errorf("unsupported os: %s", sys)
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,7 @@ func Prompt(prompt string, def bool) (bool, error) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// normalize the answer
 | 
			
		||||
	ans = strings.ToLower(strings.TrimRight(ans, "\n"))
 | 
			
		||||
	ans = strings.ToLower(strings.TrimSpace(ans))
 | 
			
		||||
 | 
			
		||||
	// return the appropriate response
 | 
			
		||||
	switch ans {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user