mirror of
https://github.com/Jguer/yay.git
synced 2025-12-09 00:03:52 -05:00
Merge pull request #928 from Jguer/fix#919
Fix #919, require explicit sort mode defined
This commit is contained in:
commit
5932b6987d
38
cmd.go
38
cmd.go
@ -312,20 +312,23 @@ func displayNumberMenu(pkgS []string) (err error) {
|
||||
return fmt.Errorf("No packages match search")
|
||||
}
|
||||
|
||||
if config.SortMode == bottomUp {
|
||||
if mode == modeAUR || mode == modeAny {
|
||||
aq.printSearch(lenpq + 1)
|
||||
}
|
||||
if mode == modeRepo || mode == modeAny {
|
||||
pq.printSearch()
|
||||
}
|
||||
} else {
|
||||
switch config.SortMode {
|
||||
case topDown:
|
||||
if mode == modeRepo || mode == modeAny {
|
||||
pq.printSearch()
|
||||
}
|
||||
if mode == modeAUR || mode == modeAny {
|
||||
aq.printSearch(lenpq + 1)
|
||||
}
|
||||
case bottomUp:
|
||||
if mode == modeAUR || mode == modeAny {
|
||||
aq.printSearch(lenpq + 1)
|
||||
}
|
||||
if mode == modeRepo || mode == modeAny {
|
||||
pq.printSearch()
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("Invalid Sort Mode. Fix with yay -Y --bottomup --save")
|
||||
}
|
||||
|
||||
if aurErr != nil {
|
||||
@ -352,9 +355,14 @@ func displayNumberMenu(pkgS []string) (err error) {
|
||||
isInclude := len(exclude) == 0 && len(otherExclude) == 0
|
||||
|
||||
for i, pkg := range pq {
|
||||
target := len(pq) - i
|
||||
if config.SortMode == topDown {
|
||||
var target int
|
||||
switch config.SortMode {
|
||||
case topDown:
|
||||
target = i + 1
|
||||
case bottomUp:
|
||||
target = len(pq) - i
|
||||
default:
|
||||
return fmt.Errorf("Invalid Sort Mode. Fix with yay -Y --bottomup --save")
|
||||
}
|
||||
|
||||
if (isInclude && include.get(target)) || (!isInclude && !exclude.get(target)) {
|
||||
@ -363,9 +371,15 @@ func displayNumberMenu(pkgS []string) (err error) {
|
||||
}
|
||||
|
||||
for i, pkg := range aq {
|
||||
target := len(aq) - i + len(pq)
|
||||
if config.SortMode == topDown {
|
||||
var target int
|
||||
|
||||
switch config.SortMode {
|
||||
case topDown:
|
||||
target = i + 1 + len(pq)
|
||||
case bottomUp:
|
||||
target = len(aq) - i + len(pq)
|
||||
default:
|
||||
return fmt.Errorf("Invalid Sort Mode. Fix with yay -Y --bottomup --save")
|
||||
}
|
||||
|
||||
if (isInclude && include.get(target)) || (!isInclude && !exclude.get(target)) {
|
||||
|
||||
18
print.go
18
print.go
@ -65,10 +65,13 @@ func (q aurQuery) printSearch(start int) {
|
||||
for i, res := range q {
|
||||
var toprint string
|
||||
if config.SearchMode == numberMenu {
|
||||
if config.SortMode == bottomUp {
|
||||
toprint += magenta(strconv.Itoa(len(q)+start-i-1) + " ")
|
||||
} else {
|
||||
switch config.SortMode {
|
||||
case topDown:
|
||||
toprint += magenta(strconv.Itoa(start+i) + " ")
|
||||
case bottomUp:
|
||||
toprint += magenta(strconv.Itoa(len(q)+start-i-1) + " ")
|
||||
default:
|
||||
fmt.Println("Invalid Sort Mode. Fix with yay -Y --bottomup --save")
|
||||
}
|
||||
} else if config.SearchMode == minimal {
|
||||
fmt.Println(res.Name)
|
||||
@ -105,10 +108,13 @@ func (s repoQuery) printSearch() {
|
||||
for i, res := range s {
|
||||
var toprint string
|
||||
if config.SearchMode == numberMenu {
|
||||
if config.SortMode == bottomUp {
|
||||
toprint += magenta(strconv.Itoa(len(s)-i) + " ")
|
||||
} else {
|
||||
switch config.SortMode {
|
||||
case topDown:
|
||||
toprint += magenta(strconv.Itoa(i+1) + " ")
|
||||
case bottomUp:
|
||||
toprint += magenta(strconv.Itoa(len(s)-i) + " ")
|
||||
default:
|
||||
fmt.Println("Invalid Sort Mode. Fix with yay -Y --bottomup --save")
|
||||
}
|
||||
} else if config.SearchMode == minimal {
|
||||
fmt.Println(res.Name())
|
||||
|
||||
19
query.go
19
query.go
@ -176,20 +176,23 @@ func syncSearch(pkgS []string) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
if config.SortMode == bottomUp {
|
||||
if mode == modeAUR || mode == modeAny {
|
||||
aq.printSearch(1)
|
||||
}
|
||||
if mode == modeRepo || mode == modeAny {
|
||||
pq.printSearch()
|
||||
}
|
||||
} else {
|
||||
switch config.SortMode {
|
||||
case topDown:
|
||||
if mode == modeRepo || mode == modeAny {
|
||||
pq.printSearch()
|
||||
}
|
||||
if mode == modeAUR || mode == modeAny {
|
||||
aq.printSearch(1)
|
||||
}
|
||||
case bottomUp:
|
||||
if mode == modeAUR || mode == modeAny {
|
||||
aq.printSearch(1)
|
||||
}
|
||||
if mode == modeRepo || mode == modeAny {
|
||||
pq.printSearch()
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("Invalid Sort Mode. Fix with yay -Y --bottomup --save")
|
||||
}
|
||||
|
||||
if aurErr != nil {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user