mirror of
https://github.com/Jguer/yay.git
synced 2024-11-06 17:17:22 +01:00
06406d7cee
Ensure aurWarnings will always be printed out in one block use '->' for printing aur warnings and ignored upgrades use '->' for conflict printing use '->' for key importing Say PGP keys not GPG keys Add back green for input prompts Use 4 spcaces over \t
87 lines
1.6 KiB
Go
87 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
alpm "github.com/jguer/go-alpm"
|
|
"os"
|
|
"strconv"
|
|
)
|
|
|
|
func questionCallback(question alpm.QuestionAny) {
|
|
qi, err := question.QuestionInstallIgnorepkg()
|
|
if err == nil {
|
|
qi.SetInstall(true)
|
|
}
|
|
|
|
qp, err := question.QuestionSelectProvider()
|
|
if err == nil {
|
|
size := 0
|
|
|
|
qp.Providers(alpmHandle).ForEach(func(pkg alpm.Package) error {
|
|
size++
|
|
return nil
|
|
})
|
|
|
|
fmt.Print(bold(cyan(":: ")))
|
|
str := bold(fmt.Sprintf(bold("There are %d providers avalable for %s:"), size, qp.Dep()))
|
|
|
|
size = 1
|
|
var db string
|
|
|
|
qp.Providers(alpmHandle).ForEach(func(pkg alpm.Package) error {
|
|
thisDb := pkg.DB().Name()
|
|
|
|
if db != thisDb {
|
|
db = thisDb
|
|
str += bold(cyan("\n:: ")) + bold("Repository "+db+"\n ")
|
|
}
|
|
str += fmt.Sprintf("%d) %s ", size, pkg.Name())
|
|
size++
|
|
return nil
|
|
})
|
|
|
|
fmt.Println(str)
|
|
|
|
for {
|
|
fmt.Print("\nEnter a number (default=1): ")
|
|
|
|
if config.NoConfirm {
|
|
fmt.Println()
|
|
break
|
|
}
|
|
|
|
reader := bufio.NewReader(os.Stdin)
|
|
numberBuf, overflow, err := reader.ReadLine()
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
break
|
|
}
|
|
|
|
if overflow {
|
|
fmt.Println("Input too long")
|
|
continue
|
|
}
|
|
|
|
if string(numberBuf) == "" {
|
|
break
|
|
}
|
|
|
|
num, err := strconv.Atoi(string(numberBuf))
|
|
if err != nil {
|
|
fmt.Printf("%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)
|
|
continue
|
|
}
|
|
|
|
qp.SetUseIndex(num - 1)
|
|
break
|
|
}
|
|
}
|
|
}
|