yay/config.go

49 lines
791 B
Go
Raw Normal View History

package main
import (
"bufio"
"fmt"
"os"
"github.com/leonelquinteros/gotext"
2021-09-08 20:28:08 +00:00
"github.com/Jguer/yay/v11/pkg/settings"
"github.com/Jguer/yay/v11/pkg/text"
)
2021-08-11 18:13:28 +00:00
// Verbosity settings for search.
2017-05-07 01:43:49 +00:00
const (
numberMenu = iota
detailed
minimal
2018-11-29 20:42:06 +00:00
)
2017-05-07 01:43:49 +00:00
2021-10-10 09:05:52 +00:00
var yayVersion = "11.0.1"
2020-05-29 22:43:18 +00:00
var localePath = "/usr/share/locale"
// YayConf holds the current config values for yay.
var config *settings.Configuration
func getInput(defaultValue string) (string, error) {
text.Info()
2021-08-11 18:13:28 +00:00
if defaultValue != "" || settings.NoConfirm {
fmt.Println(defaultValue)
return defaultValue, nil
}
reader := bufio.NewReader(os.Stdin)
buf, overflow, err := reader.ReadLine()
if err != nil {
return "", err
}
if overflow {
return "", fmt.Errorf(gotext.Get("input too long"))
}
return string(buf), nil
}