Sfoglia il codice sorgente

Move intrange to its own module

types is pretty generic as a module name, this should be split into
seperate modules.
morganamilo 5 anni fa
parent
commit
cff358d5d6
12 ha cambiato i file con 24 aggiunte e 18 eliminazioni
  1. 1 1
      clean.go
  2. 2 2
      cmd.go
  3. 1 1
      depCheck.go
  4. 1 1
      depOrder.go
  5. 1 1
      depPool.go
  6. 4 3
      install.go
  7. 1 1
      parser.go
  8. 1 1
      pkg/types/intrange.go
  9. 1 1
      pkg/types/intrange_test.go
  10. 4 3
      print.go
  11. 3 1
      query.go
  12. 4 2
      upgrade.go

+ 1 - 1
clean.go

@@ -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.

+ 2 - 2
cmd.go

@@ -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

+ 1 - 1
depCheck.go

@@ -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) {

+ 1 - 1
depOrder.go

@@ -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"
 )
 

+ 1 - 1
depPool.go

@@ -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"
 )
 

+ 4 - 3
install.go

@@ -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") {

+ 1 - 1
parser.go

@@ -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"
 )
 

+ 1 - 1
pkg/types/intrange.go

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

+ 1 - 1
pkg/types/intrange_test.go

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

+ 4 - 3
print.go

@@ -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)

+ 3 - 1
query.go

@@ -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)
 	}

+ 4 - 2
upgrade.go

@@ -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