Fixes no confirms

This commit is contained in:
Jguer 2017-08-02 22:56:45 +01:00
parent 5ad1772bba
commit 262b158a34
2 changed files with 30 additions and 24 deletions

View file

@ -31,11 +31,15 @@ Yay was created with a few objectives in mind and based on the design of yaourt
- `yay -Cd` cleans unneeded dependencies - `yay -Cd` cleans unneeded dependencies
- `yay -G` downloads PKGBuild from ABS or AUR - `yay -G` downloads PKGBuild from ABS or AUR
![Yay Syu](http://jguer.github.io/yay/yayupgrade.png "yay -Syu")
![Yay Qstats](http://jguer.github.io/yay/yay2.png "yay -Qstats") ![Yay Qstats](http://jguer.github.io/yay/yay2.png "yay -Qstats")
![Yay NumberMenu](http://jguer.github.io/yay/yay3.png "yay gtk-theme") ![Yay NumberMenu](http://jguer.github.io/yay/yay3.png "yay gtk-theme")
### Changelog ### Changelog
#### 2.165
- Upgrade list now allows skipping upgrade install.
#### 2.159 #### 2.159
- Qstats now warns about packages not available in AUR. - Qstats now warns about packages not available in AUR.
@ -45,7 +49,6 @@ Yay was created with a few objectives in mind and based on the design of yaourt
- Pacman backend rewritten and simplified - Pacman backend rewritten and simplified
- Added config framework. - Added config framework.
#### 1.115 #### 1.115
- Added AUR completions (updates on first completion every 48h) - Added AUR completions (updates on first completion every 48h)

View file

@ -292,35 +292,38 @@ func upgradePkgs(flags []string) error {
return err return err
} }
var repoNums []int
var aurNums []int
sort.Sort(repoUp) sort.Sort(repoUp)
fmt.Printf("\x1b[1;34;1m:: \x1b[0m\x1b[1m%d Packages to upgrade.\x1b[0m\n", len(aurUp)+len(repoUp)) fmt.Printf("\x1b[1;34;1m:: \x1b[0m\x1b[1m%d Packages to upgrade.\x1b[0m\n", len(aurUp)+len(repoUp))
repoUp.Print(len(aurUp)) repoUp.Print(len(aurUp))
aurUp.Print(0) aurUp.Print(0)
fmt.Print("\x1b[32mEnter packages you don't want to upgrade.\x1b[0m\nNumbers: ")
reader := bufio.NewReader(os.Stdin)
numberBuf, overflow, err := reader.ReadLine() if !config.YayConf.NoConfirm {
if err != nil || overflow { fmt.Print("\x1b[32mEnter packages you don't want to upgrade.\x1b[0m\nNumbers: ")
fmt.Println(err) reader := bufio.NewReader(os.Stdin)
return err
}
result := strings.Fields(string(numberBuf)) numberBuf, overflow, err := reader.ReadLine()
var repoNums []int if err != nil || overflow {
var aurNums []int fmt.Println(err)
for _, numS := range result { return err
num, err := strconv.Atoi(numS)
if err != nil {
continue
} }
if num > len(aurUp)+len(repoUp)-1 || num < 0 {
continue result := strings.Fields(string(numberBuf))
} else if num < len(aurUp) { for _, numS := range result {
num = len(aurUp) - num - 1 num, err := strconv.Atoi(numS)
aurNums = append(aurNums, num) if err != nil {
} else { continue
num = len(aurUp) + len(repoUp) - num - 1 }
repoNums = append(repoNums, num) if num > len(aurUp)+len(repoUp)-1 || num < 0 {
continue
} else if num < len(aurUp) {
num = len(aurUp) - num - 1
aurNums = append(aurNums, num)
} else {
num = len(aurUp) + len(repoUp) - num - 1
repoNums = append(repoNums, num)
}
} }
} }
@ -336,7 +339,7 @@ func upgradePkgs(flags []string) error {
repoNames = append(repoNames, k.Name) repoNames = append(repoNames, k.Name)
} }
err := config.PassToPacman("-S", repoNames, flags) err := config.PassToPacman("-S", repoNames, append(flags, "--noconfirm"))
if err != nil { if err != nil {
fmt.Println("Error upgrading repo packages.") fmt.Println("Error upgrading repo packages.")
} }