Move intrange to its own module

types is pretty generic as a module name, this should be split into
seperate modules.
This commit is contained in:
morganamilo 2019-10-16 22:36:08 +01:00
parent f2579f26a3
commit cff358d5d6
No known key found for this signature in database
GPG key ID: 6FE9E7996B0B082E
12 changed files with 24 additions and 18 deletions

View file

@ -6,7 +6,7 @@ import (
"os"
"path/filepath"
"github.com/Jguer/yay/v9/pkg/stringset"
"github.com/Jguer/yay/v9/pkg/stringset"
)
// GetPkgbuild gets the pkgbuild of the package 'pkg' trying the ABS first and then the AUR trying the ABS first and then the AUR.

4
cmd.go
View file

@ -8,7 +8,7 @@ import (
alpm "github.com/Jguer/go-alpm"
"github.com/Jguer/yay/v9/pkg/completion"
"github.com/Jguer/yay/v9/pkg/types"
"github.com/Jguer/yay/v9/pkg/intrange"
)
var cmdArgs = makeArguments()
@ -355,7 +355,7 @@ func displayNumberMenu(pkgS []string) (err error) {
return fmt.Errorf("Input too long")
}
include, exclude, _, otherExclude := types.ParseNumberMenu(string(numberBuf))
include, exclude, _, otherExclude := intrange.ParseNumberMenu(string(numberBuf))
arguments := cmdArgs.copyGlobal()
isInclude := len(exclude) == 0 && len(otherExclude) == 0

View file

@ -7,7 +7,7 @@ import (
"sync"
alpm "github.com/Jguer/go-alpm"
"github.com/Jguer/yay/v9/pkg/stringset"
"github.com/Jguer/yay/v9/pkg/stringset"
)
func (dp *depPool) checkInnerConflict(name string, conflict string, conflicts stringset.MapStringSet) {

View file

@ -2,7 +2,7 @@ package main
import (
alpm "github.com/Jguer/go-alpm"
"github.com/Jguer/yay/v9/pkg/stringset"
"github.com/Jguer/yay/v9/pkg/stringset"
rpc "github.com/mikkeloscar/aur"
)

View file

@ -6,7 +6,7 @@ import (
"sync"
alpm "github.com/Jguer/go-alpm"
"github.com/Jguer/yay/v9/pkg/stringset"
"github.com/Jguer/yay/v9/pkg/stringset"
rpc "github.com/mikkeloscar/aur"
)

View file

@ -11,8 +11,9 @@ import (
alpm "github.com/Jguer/go-alpm"
"github.com/Jguer/yay/v9/pkg/completion"
"github.com/Jguer/yay/v9/pkg/types"
"github.com/Jguer/yay/v9/pkg/intrange"
"github.com/Jguer/yay/v9/pkg/stringset"
"github.com/Jguer/yay/v9/pkg/types"
gosrc "github.com/Morganamilo/go-srcinfo"
)
@ -584,7 +585,7 @@ func cleanNumberMenu(bases []Base, installed stringset.StringSet, hasClean bool)
return nil, err
}
cInclude, cExclude, cOtherInclude, cOtherExclude := types.ParseNumberMenu(cleanInput)
cInclude, cExclude, cOtherInclude, cOtherExclude := intrange.ParseNumberMenu(cleanInput)
cIsInclude := len(cExclude) == 0 && len(cOtherExclude) == 0
if cOtherInclude.Get("abort") || cOtherInclude.Get("ab") {
@ -669,7 +670,7 @@ func editDiffNumberMenu(bases []Base, installed stringset.StringSet, diff bool)
}
}
eInclude, eExclude, eOtherInclude, eOtherExclude := types.ParseNumberMenu(editInput)
eInclude, eExclude, eOtherInclude, eOtherExclude := intrange.ParseNumberMenu(editInput)
eIsInclude := len(eExclude) == 0 && len(eOtherExclude) == 0
if eOtherInclude.Get("abort") || eOtherInclude.Get("ab") {

View file

@ -9,7 +9,7 @@ import (
"strconv"
"strings"
"github.com/Jguer/yay/v9/pkg/stringset"
"github.com/Jguer/yay/v9/pkg/stringset"
rpc "github.com/mikkeloscar/aur"
)

View file

@ -1,4 +1,4 @@
package types
package intrange
import (
"strconv"

View file

@ -1,4 +1,4 @@
package types
package intrange
import (
"github.com/Jguer/yay/v9/pkg/stringset"

View file

@ -12,7 +12,8 @@ import (
"strings"
"time"
"github.com/Jguer/yay/v9/pkg/types"
"github.com/Jguer/yay/v9/pkg/intrange"
"github.com/Jguer/yay/v9/pkg/stringset"
rpc "github.com/mikkeloscar/aur"
)
@ -178,8 +179,8 @@ func (u upSlice) print() {
packNameLen := len(pack.StylizedNameWithRepository())
version, _ := getVersionDiff(pack.LocalVersion, pack.RemoteVersion)
packVersionLen := len(version)
longestName = types.Max(packNameLen, longestName)
longestVersion = types.Max(packVersionLen, longestVersion)
longestName = intrange.Max(packNameLen, longestName)
longestVersion = intrange.Max(packVersionLen, longestVersion)
}
namePadding := fmt.Sprintf("%%-%ds ", longestName)

View file

@ -9,7 +9,9 @@ import (
"time"
alpm "github.com/Jguer/go-alpm"
"github.com/Jguer/yay/v9/pkg/intrange"
"github.com/Jguer/yay/v9/pkg/types"
"github.com/Jguer/yay/v9/pkg/stringset"
rpc "github.com/mikkeloscar/aur"
)
@ -519,7 +521,7 @@ func aurInfo(names []string, warnings *aurWarnings) ([]*rpc.Pkg, error) {
}
for n := 0; n < len(names); n += config.RequestSplitN {
max := types.Min(len(names), n+config.RequestSplitN)
max := intrange.Min(len(names), n+config.RequestSplitN)
wg.Add(1)
go makeRequest(n, max)
}

View file

@ -7,8 +7,10 @@ import (
"unicode"
alpm "github.com/Jguer/go-alpm"
"github.com/Jguer/yay/v9/pkg/types"
"github.com/Jguer/yay/v9/pkg/intrange"
"github.com/Jguer/yay/v9/pkg/stringset"
"github.com/Jguer/yay/v9/pkg/types"
rpc "github.com/mikkeloscar/aur"
)
@ -365,7 +367,7 @@ func upgradePkgs(aurUp, repoUp upSlice) (stringset.StringSet, stringset.StringSe
//upgrade menu asks you which packages to NOT upgrade so in this case
//include and exclude are kind of swapped
//include, exclude, other := parseNumberMenu(string(numberBuf))
include, exclude, otherInclude, otherExclude := types.ParseNumberMenu(numbers)
include, exclude, otherInclude, otherExclude := intrange.ParseNumberMenu(numbers)
isInclude := len(exclude) == 0 && len(otherExclude) == 0