Merge pull request #461 from Morganamilo/repoaur

Support --aur/--repo for -Ss and -Y
This commit is contained in:
Anna 2018-06-04 20:37:07 +01:00 committed by GitHub
commit b56afaaee3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 63 additions and 25 deletions

52
cmd.go
View file

@ -441,23 +441,43 @@ func handleRemove() (err error) {
// NumberMenu presents a CLI for selecting packages to install.
func numberMenu(pkgS []string, flags []string) (err error) {
aurQ, aurErr := narrowSearch(pkgS, true)
numaq := len(aurQ)
repoQ, numpq, err := queryRepo(pkgS)
if err != nil {
return
pkgS = removeInvalidTargets(pkgS)
var aurErr error
var repoErr error
var aq aurQuery
var pq repoQuery
var lenaq int
var lenpq int
if mode == ModeAUR || mode == ModeAny {
aq, aurErr = narrowSearch(pkgS, true)
lenaq = len(aq)
}
if mode == ModeRepo || mode == ModeAny {
pq, lenpq, repoErr = queryRepo(pkgS)
if repoErr != nil {
return err
}
}
if numpq == 0 && numaq == 0 {
return fmt.Errorf("no packages match search")
if lenpq == 0 && lenaq == 0 {
return fmt.Errorf("No packages match search")
}
if config.SortMode == BottomUp {
aurQ.printSearch(numpq + 1)
repoQ.printSearch()
if mode == ModeAUR || mode == ModeAny {
aq.printSearch(lenpq + 1)
}
if mode == ModeRepo || mode == ModeAny {
pq.printSearch()
}
} else {
repoQ.printSearch()
aurQ.printSearch(numpq + 1)
if mode == ModeRepo || mode == ModeAny {
pq.printSearch()
}
if mode == ModeAUR || mode == ModeAny {
aq.printSearch(lenpq + 1)
}
}
if aurErr != nil {
@ -484,8 +504,8 @@ func numberMenu(pkgS []string, flags []string) (err error) {
isInclude := len(exclude) == 0 && len(otherExclude) == 0
for i, pkg := range repoQ {
target := len(repoQ) - i
for i, pkg := range pq {
target := len(pq) - i
if config.SortMode == TopDown {
target = i + 1
}
@ -498,10 +518,10 @@ func numberMenu(pkgS []string, flags []string) (err error) {
}
}
for i, pkg := range aurQ {
target := len(aurQ) - i + len(repoQ)
for i, pkg := range aq {
target := len(aq) - i + len(pq)
if config.SortMode == TopDown {
target = i + 1 + len(repoQ)
target = i + 1 + len(pq)
}
if isInclude && include.get(target) {

View file

@ -159,18 +159,36 @@ func narrowSearch(pkgS []string, sortS bool) (aurQuery, error) {
// SyncSearch presents a query to the local repos and to the AUR.
func syncSearch(pkgS []string) (err error) {
aq, aurErr := narrowSearch(pkgS, true)
pq, _, err := queryRepo(pkgS)
if err != nil {
return err
pkgS = removeInvalidTargets(pkgS)
var aurErr error
var repoErr error
var aq aurQuery
var pq repoQuery
if mode == ModeAUR || mode == ModeAny {
aq, aurErr = narrowSearch(pkgS, true)
}
if mode == ModeRepo || mode == ModeAny {
pq, _, repoErr = queryRepo(pkgS)
if repoErr != nil {
return err
}
}
if config.SortMode == BottomUp {
aq.printSearch(1)
pq.printSearch()
if mode == ModeAUR || mode == ModeAny {
aq.printSearch(1)
}
if mode == ModeRepo || mode == ModeAny {
pq.printSearch()
}
} else {
pq.printSearch()
aq.printSearch(1)
if mode == ModeRepo || mode == ModeAny {
pq.printSearch()
}
if mode == ModeAUR || mode == ModeAny {
aq.printSearch(1)
}
}
if aurErr != nil {

2
vcs.go
View file

@ -18,7 +18,7 @@ type vcsInfo map[string]shaInfos
type shaInfos map[string]shaInfo
type shaInfo struct {
Protocols []string `json:"protocols"`
Branch string `json:"branch"`
Branch string `json:"branch"`
SHA string `json:"sha"`
}