mirror of
https://github.com/Jguer/yay.git
synced 2024-11-06 09:07:21 +01:00
Print errors on stderr
This makes a start on fixing https://github.com/Jguer/yay/issues/715 It is by no means a complete solution, but instead a start
This commit is contained in:
parent
96a4d9637c
commit
52bf777e67
@ -62,12 +62,12 @@ func questionCallback(question alpm.QuestionAny) {
|
||||
numberBuf, overflow, err := reader.ReadLine()
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
break
|
||||
}
|
||||
|
||||
if overflow {
|
||||
fmt.Println("Input too long")
|
||||
fmt.Fprintln(os.Stderr, "Input too long")
|
||||
continue
|
||||
}
|
||||
|
||||
@ -77,12 +77,12 @@ func questionCallback(question alpm.QuestionAny) {
|
||||
|
||||
num, err := strconv.Atoi(string(numberBuf))
|
||||
if err != nil {
|
||||
fmt.Printf("%s invalid number: %s\n", red("error:"), string(numberBuf))
|
||||
fmt.Fprintf(os.Stderr, "%s invalid number: %s\n", red("error:"), string(numberBuf))
|
||||
continue
|
||||
}
|
||||
|
||||
if num < 1 || num > size {
|
||||
fmt.Printf("%s invalid value: %d is not between %d and %d\n", red("error:"), num, 1, size)
|
||||
fmt.Fprintf(os.Stderr, "%s invalid value: %d is not between %d and %d\n", red("error:"), num, 1, size)
|
||||
continue
|
||||
}
|
||||
|
||||
|
6
clean.go
6
clean.go
@ -207,14 +207,14 @@ func cleanAfter(bases []Base) {
|
||||
fmt.Printf(bold(cyan("::")+" Cleaning (%d/%d): %s\n"), i+1, len(bases), cyan(dir))
|
||||
_, stderr, err := capture(passToGit(dir, "reset", "--hard", "HEAD"))
|
||||
if err != nil {
|
||||
fmt.Printf("error resetting %s: %s", base.String(), stderr)
|
||||
fmt.Fprintf(os.Stderr, "error resetting %s: %s", base.String(), stderr)
|
||||
}
|
||||
|
||||
show(passToGit(dir, "clean", "-fx"))
|
||||
} else {
|
||||
fmt.Printf(bold(cyan("::")+" Deleting (%d/%d): %s\n"), i+1, len(bases), cyan(dir))
|
||||
if err := os.RemoveAll(dir); err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -225,7 +225,7 @@ func cleanBuilds(bases []Base) {
|
||||
dir := filepath.Join(config.BuildDir, base.Pkgbase())
|
||||
fmt.Printf(bold(cyan("::")+" Deleting (%d/%d): %s\n"), i+1, len(bases), cyan(dir))
|
||||
if err := os.RemoveAll(dir); err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
4
cmd.go
4
cmd.go
@ -328,8 +328,8 @@ func displayNumberMenu(pkgS []string) (err error) {
|
||||
}
|
||||
|
||||
if aurErr != nil {
|
||||
fmt.Printf("Error during AUR search: %s\n", aurErr)
|
||||
fmt.Println("Showing repo packages only")
|
||||
fmt.Fprintf(os.Stderr, "Error during AUR search: %s\n", aurErr)
|
||||
fmt.Fprintln(os.Stderr, "Showing repo packages only")
|
||||
}
|
||||
|
||||
fmt.Println(bold(green(arrow + " Packages to install (eg: 1 2 3, 1-3 or ^4)")))
|
||||
|
18
config.go
18
config.go
@ -214,7 +214,7 @@ func editor() (string, []string) {
|
||||
case config.Editor != "":
|
||||
editor, err := exec.LookPath(config.Editor)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
} else {
|
||||
return editor, strings.Fields(config.EditorFlags)
|
||||
}
|
||||
@ -223,7 +223,7 @@ func editor() (string, []string) {
|
||||
editorArgs := strings.Fields(os.Getenv("EDITOR"))
|
||||
editor, err := exec.LookPath(editorArgs[0])
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
} else {
|
||||
return editor, editorArgs[1:]
|
||||
}
|
||||
@ -232,21 +232,21 @@ func editor() (string, []string) {
|
||||
editorArgs := strings.Fields(os.Getenv("VISUAL"))
|
||||
editor, err := exec.LookPath(editorArgs[0])
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
} else {
|
||||
return editor, editorArgs[1:]
|
||||
}
|
||||
fallthrough
|
||||
default:
|
||||
fmt.Println()
|
||||
fmt.Println(bold(red(arrow)), bold(cyan("$EDITOR")), bold("is not set"))
|
||||
fmt.Println(bold(red(arrow)) + bold(" Please add ") + bold(cyan("$EDITOR")) + bold(" or ") + bold(cyan("$VISUAL")) + bold(" to your environment variables."))
|
||||
fmt.Fprintln(os.Stderr)
|
||||
fmt.Fprintln(os.Stderr, bold(red(arrow)), bold(cyan("$EDITOR")), bold("is not set"))
|
||||
fmt.Fprintln(os.Stderr, bold(red(arrow))+bold(" Please add ")+bold(cyan("$EDITOR"))+bold(" or ")+bold(cyan("$VISUAL"))+bold(" to your environment variables."))
|
||||
|
||||
for {
|
||||
fmt.Print(green(bold(arrow + " Edit PKGBUILD with: ")))
|
||||
editorInput, err := getInput("")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
continue
|
||||
}
|
||||
|
||||
@ -254,7 +254,7 @@ func editor() (string, []string) {
|
||||
|
||||
editor, err := exec.LookPath(editorArgs[0])
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
continue
|
||||
}
|
||||
return editor, editorArgs[1:]
|
||||
@ -318,7 +318,7 @@ func (config Configuration) String() string {
|
||||
enc := json.NewEncoder(&buf)
|
||||
enc.SetIndent("", "\t")
|
||||
if err := enc.Encode(config); err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
29
depCheck.go
29
depCheck.go
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
@ -74,23 +75,23 @@ func (ds *depSolver) CheckMissing() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
fmt.Println(bold(red(arrow+" Error: ")) + "Could not find all required packages:")
|
||||
fmt.Fprintln(os.Stderr, bold(red(arrow+" Error: "))+"Could not find all required packages:")
|
||||
for dep, trees := range missing.Missing {
|
||||
for _, tree := range trees {
|
||||
|
||||
fmt.Print(" ", cyan(dep))
|
||||
fmt.Fprint(os.Stderr, " ", cyan(dep))
|
||||
|
||||
if len(tree) == 0 {
|
||||
fmt.Print(" (Target")
|
||||
fmt.Fprint(os.Stderr, " (Target")
|
||||
} else {
|
||||
fmt.Print(" (Wanted by: ")
|
||||
fmt.Fprint(os.Stderr, " (Wanted by: ")
|
||||
for n := 0; n < len(tree)-1; n++ {
|
||||
fmt.Print(cyan(tree[n]), " -> ")
|
||||
fmt.Fprint(os.Stderr, cyan(tree[n]), " -> ")
|
||||
}
|
||||
fmt.Print(cyan(tree[len(tree)-1]))
|
||||
fmt.Fprint(os.Stderr, cyan(tree[len(tree)-1]))
|
||||
}
|
||||
|
||||
fmt.Println(")")
|
||||
fmt.Fprintln(os.Stderr, ")")
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,11 +264,11 @@ func (ds *depSolver) CheckConflicts() (mapStringSet, error) {
|
||||
|
||||
formatConflicts := func(conflicts mapStringSet, inner bool, s string) {
|
||||
if len(conflicts) != 0 {
|
||||
fmt.Println()
|
||||
fmt.Fprintln(os.Stderr)
|
||||
if inner {
|
||||
fmt.Println(bold(red(arrow)), bold("Inner conflicts found:"))
|
||||
fmt.Fprintln(os.Stderr, bold(red(arrow)), bold("Inner conflicts found:"))
|
||||
} else {
|
||||
fmt.Println(bold(red(arrow)), bold("Package conflicts found:"))
|
||||
fmt.Fprintln(os.Stderr, bold(red(arrow)), bold("Package conflicts found:"))
|
||||
}
|
||||
|
||||
printConflict := func(name string, pkgs stringSet) {
|
||||
@ -277,7 +278,7 @@ func (ds *depSolver) CheckConflicts() (mapStringSet, error) {
|
||||
}
|
||||
str = strings.TrimSuffix(str, ",")
|
||||
|
||||
fmt.Println(str)
|
||||
fmt.Fprintln(os.Stderr, str)
|
||||
}
|
||||
|
||||
for _, pkg := range ds.Repo {
|
||||
@ -318,9 +319,9 @@ func (ds *depSolver) CheckConflicts() (mapStringSet, error) {
|
||||
return nil, fmt.Errorf("Package conflicts can not be resolved with noconfirm, aborting")
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
fmt.Println(bold(red(arrow)), bold("Conflicting packages will have to be confirmed manually"))
|
||||
fmt.Println()
|
||||
fmt.Fprintln(os.Stderr)
|
||||
fmt.Fprintln(os.Stderr, bold(red(arrow)), bold("Conflicting packages will have to be confirmed manually"))
|
||||
fmt.Fprintln(os.Stderr)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,11 +165,11 @@ func getPkgbuilds(pkgs []string) error {
|
||||
name := base.Pkgbase()
|
||||
_, err = os.Stat(filepath.Join(wd, name))
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
fmt.Println(bold(red(smallArrow)), err)
|
||||
fmt.Fprintln(os.Stderr, bold(red(smallArrow)), err)
|
||||
continue
|
||||
} else if os.IsNotExist(err) || cmdArgs.existsArg("f", "force") || shouldUseGit(filepath.Join(wd, name)) {
|
||||
if err = os.RemoveAll(filepath.Join(wd, name)); err != nil {
|
||||
fmt.Println(bold(red(smallArrow)), err)
|
||||
fmt.Fprintln(os.Stderr, bold(red(smallArrow)), err)
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
@ -249,11 +249,11 @@ func getPkgbuildsfromABS(pkgs []string, path string) (bool, error) {
|
||||
|
||||
_, err = os.Stat(filepath.Join(path, name))
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
fmt.Println(bold(red(smallArrow)), err)
|
||||
fmt.Fprintln(os.Stderr, bold(red(smallArrow)), err)
|
||||
continue
|
||||
} else if os.IsNotExist(err) || cmdArgs.existsArg("f", "force") {
|
||||
if err = os.RemoveAll(filepath.Join(path, name)); err != nil {
|
||||
fmt.Println(bold(red(smallArrow)), err)
|
||||
fmt.Fprintln(os.Stderr, bold(red(smallArrow)), err)
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
|
2
exec.go
2
exec.go
@ -47,7 +47,7 @@ func updateSudo() {
|
||||
for {
|
||||
err := show(exec.Command("sudo", "-v"))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
@ -434,9 +434,9 @@ nextpkg:
|
||||
|
||||
if len(incompatible) > 0 {
|
||||
fmt.Println()
|
||||
fmt.Print(bold(yellow(arrow)) + " The following packages are not compatible with your architecture:")
|
||||
fmt.Print(bold(yellow(arrow))+" The following packages are not compatible with your architecture:")
|
||||
for pkg := range incompatible {
|
||||
fmt.Print(" " + cyan((basesMap[pkg].String())))
|
||||
fmt.Print(" "+cyan(basesMap[pkg].String()))
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
@ -763,7 +763,7 @@ func parseSrcinfoFiles(bases []Base, errIsFatal bool) (map[string]*gosrc.Srcinfo
|
||||
pkgbuild, err := gosrc.ParseFile(filepath.Join(dir, ".SRCINFO"))
|
||||
if err != nil {
|
||||
if !errIsFatal {
|
||||
fmt.Printf("failed to parse %s -- skipping: %s\n", base.String(), err)
|
||||
fmt.Fprintf(os.Stderr, "failed to parse %s -- skipping: %s\n", base.String(), err)
|
||||
continue
|
||||
}
|
||||
return nil, fmt.Errorf("failed to parse %s: %s", base.String(), err)
|
||||
@ -1057,7 +1057,7 @@ func buildInstallPkgbuilds(ds *depSolver, srcinfos map[string]*gosrc.Srcinfo, pa
|
||||
|
||||
err = saveVCSInfo()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
}
|
||||
|
||||
if len(depArguments.targets) > 0 {
|
||||
|
6
main.go
6
main.go
@ -184,7 +184,7 @@ func initAlpmHandle() error {
|
||||
func exitOnError(err error) {
|
||||
if err != nil {
|
||||
if str := err.Error(); str != "" {
|
||||
fmt.Println(str)
|
||||
fmt.Fprintln(os.Stderr, str)
|
||||
}
|
||||
cleanup()
|
||||
os.Exit(1)
|
||||
@ -194,7 +194,7 @@ func exitOnError(err error) {
|
||||
func cleanup() int {
|
||||
if alpmHandle != nil {
|
||||
if err := alpmHandle.Release(); err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
return 1
|
||||
}
|
||||
}
|
||||
@ -204,7 +204,7 @@ func cleanup() int {
|
||||
|
||||
func main() {
|
||||
if 0 == os.Geteuid() {
|
||||
fmt.Println("Please avoid running yay as root/sudo.")
|
||||
fmt.Fprintln(os.Stderr, "Please avoid running yay as root/sudo.")
|
||||
}
|
||||
|
||||
exitOnError(setPaths())
|
||||
|
14
print.go
14
print.go
@ -371,7 +371,7 @@ outer:
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println(red(bold("error:")), "package '"+pkg+"' was not found")
|
||||
fmt.Fprintln(os.Stderr, red(bold("error:")), "package '"+pkg+"' was not found")
|
||||
missing = true
|
||||
}
|
||||
|
||||
@ -395,7 +395,7 @@ func (item item) print(buildTime time.Time) {
|
||||
date, err := time.Parse(time.RFC1123Z, item.PubDate)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
} else {
|
||||
fd = formatTime(int(date.Unix()))
|
||||
if _, double, _ := cmdArgs.getArg("news", "w"); !double && !buildTime.IsZero() {
|
||||
@ -546,7 +546,7 @@ func providerMenu(dep string, providers providers) *rpc.Pkg {
|
||||
size++
|
||||
}
|
||||
|
||||
fmt.Println(str)
|
||||
fmt.Fprintln(os.Stderr, str)
|
||||
|
||||
for {
|
||||
fmt.Print("\nEnter a number (default=1): ")
|
||||
@ -560,12 +560,12 @@ func providerMenu(dep string, providers providers) *rpc.Pkg {
|
||||
numberBuf, overflow, err := reader.ReadLine()
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
break
|
||||
}
|
||||
|
||||
if overflow {
|
||||
fmt.Println("Input too long")
|
||||
fmt.Fprintln(os.Stderr, "Input too long")
|
||||
continue
|
||||
}
|
||||
|
||||
@ -575,12 +575,12 @@ func providerMenu(dep string, providers providers) *rpc.Pkg {
|
||||
|
||||
num, err := strconv.Atoi(string(numberBuf))
|
||||
if err != nil {
|
||||
fmt.Printf("%s invalid number: %s\n", red("error:"), string(numberBuf))
|
||||
fmt.Fprintf(os.Stderr, "%s invalid number: %s\n", red("error:"), string(numberBuf))
|
||||
continue
|
||||
}
|
||||
|
||||
if num < 1 || num > size {
|
||||
fmt.Printf("%s invalid value: %d is not between %d and %d\n", red("error:"), num, 1, size)
|
||||
fmt.Fprintf(os.Stderr, "%s invalid value: %d is not between %d and %d\n", red("error:"), num, 1, size)
|
||||
continue
|
||||
}
|
||||
|
||||
|
7
query.go
7
query.go
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -192,8 +193,8 @@ func syncSearch(pkgS []string) (err error) {
|
||||
}
|
||||
|
||||
if aurErr != nil {
|
||||
fmt.Printf("Error during AUR search: %s\n", aurErr)
|
||||
fmt.Println("Showing Repo packages only")
|
||||
fmt.Fprintf(os.Stderr, "Error during AUR search: %s\n", aurErr)
|
||||
fmt.Fprintln(os.Stderr, "Showing Repo packages only")
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -220,7 +221,7 @@ func syncInfo(pkgS []string) (err error) {
|
||||
info, err = aurInfoPrint(noDb)
|
||||
if err != nil {
|
||||
missing = true
|
||||
fmt.Println(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user