mirror of
https://github.com/Jguer/yay.git
synced 2024-11-06 09:07:21 +01:00
fix(cmdArgs): reorder args
This commit is contained in:
parent
7a32ffdd37
commit
a0cff2b622
6
clean.go
6
clean.go
@ -38,21 +38,21 @@ func removeVCSPackage(pkgs []string) {
|
||||
}
|
||||
|
||||
// CleanDependencies removes all dangling dependencies in system
|
||||
func cleanDependencies(cmdArgs *settings.Arguments, removeOptional bool, alpmHandle *alpm.Handle) error {
|
||||
func cleanDependencies(cmdArgs *settings.Arguments, alpmHandle *alpm.Handle, removeOptional bool) error {
|
||||
hanging, err := hangingPackages(removeOptional, alpmHandle)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(hanging) != 0 {
|
||||
return cleanRemove(hanging, cmdArgs)
|
||||
return cleanRemove(cmdArgs, hanging)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CleanRemove sends a full removal command to pacman with the pkgName slice
|
||||
func cleanRemove(pkgNames []string, cmdArgs *settings.Arguments) error {
|
||||
func cleanRemove(cmdArgs *settings.Arguments, pkgNames []string) error {
|
||||
if len(pkgNames) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
32
cmd.go
32
cmd.go
@ -137,7 +137,7 @@ getpkgbuild specific options:
|
||||
-f --force Force download for existing ABS packages`)
|
||||
}
|
||||
|
||||
func handleCmd(alpmHandle *alpm.Handle, cmdArgs *settings.Arguments) error {
|
||||
func handleCmd(cmdArgs *settings.Arguments, alpmHandle *alpm.Handle) error {
|
||||
if cmdArgs.ExistsArg("h", "help") {
|
||||
return handleHelp(cmdArgs)
|
||||
}
|
||||
@ -155,27 +155,27 @@ func handleCmd(alpmHandle *alpm.Handle, cmdArgs *settings.Arguments) error {
|
||||
case "F", "files":
|
||||
return show(passToPacman(cmdArgs))
|
||||
case "Q", "query":
|
||||
return handleQuery(alpmHandle, cmdArgs)
|
||||
return handleQuery(cmdArgs, alpmHandle)
|
||||
case "R", "remove":
|
||||
return handleRemove(cmdArgs)
|
||||
case "S", "sync":
|
||||
return handleSync(alpmHandle, cmdArgs)
|
||||
return handleSync(cmdArgs, alpmHandle)
|
||||
case "T", "deptest":
|
||||
return show(passToPacman(cmdArgs))
|
||||
case "U", "upgrade":
|
||||
return show(passToPacman(cmdArgs))
|
||||
case "G", "getpkgbuild":
|
||||
return handleGetpkgbuild(alpmHandle, cmdArgs)
|
||||
return handleGetpkgbuild(cmdArgs, alpmHandle)
|
||||
case "P", "show":
|
||||
return handlePrint(alpmHandle, cmdArgs)
|
||||
return handlePrint(cmdArgs, alpmHandle)
|
||||
case "Y", "--yay":
|
||||
return handleYay(alpmHandle, cmdArgs)
|
||||
return handleYay(cmdArgs, alpmHandle)
|
||||
}
|
||||
|
||||
return fmt.Errorf(gotext.Get("unhandled operation"))
|
||||
}
|
||||
|
||||
func handleQuery(alpmHandle *alpm.Handle, cmdArgs *settings.Arguments) error {
|
||||
func handleQuery(cmdArgs *settings.Arguments, alpmHandle *alpm.Handle) error {
|
||||
if cmdArgs.ExistsArg("u", "upgrades") {
|
||||
return printUpdateList(cmdArgs, alpmHandle, cmdArgs.ExistsDouble("u", "sysupgrade"))
|
||||
}
|
||||
@ -194,7 +194,7 @@ func handleVersion() {
|
||||
fmt.Printf("yay v%s - libalpm v%s\n", yayVersion, alpm.Version())
|
||||
}
|
||||
|
||||
func handlePrint(alpmHandle *alpm.Handle, cmdArgs *settings.Arguments) (err error) {
|
||||
func handlePrint(cmdArgs *settings.Arguments, alpmHandle *alpm.Handle) (err error) {
|
||||
switch {
|
||||
case cmdArgs.ExistsArg("d", "defaultconfig"):
|
||||
tmpConfig := settings.MakeConfig()
|
||||
@ -220,32 +220,32 @@ func handlePrint(alpmHandle *alpm.Handle, cmdArgs *settings.Arguments) (err erro
|
||||
return err
|
||||
}
|
||||
|
||||
func handleYay(alpmHandle *alpm.Handle, cmdArgs *settings.Arguments) error {
|
||||
func handleYay(cmdArgs *settings.Arguments, alpmHandle *alpm.Handle) error {
|
||||
if cmdArgs.ExistsArg("gendb") {
|
||||
return createDevelDB(config.Runtime.VCSPath, alpmHandle)
|
||||
}
|
||||
if cmdArgs.ExistsDouble("c") {
|
||||
return cleanDependencies(cmdArgs, true, alpmHandle)
|
||||
return cleanDependencies(cmdArgs, alpmHandle, true)
|
||||
}
|
||||
if cmdArgs.ExistsArg("c", "clean") {
|
||||
return cleanDependencies(cmdArgs, false, alpmHandle)
|
||||
return cleanDependencies(cmdArgs, alpmHandle, false)
|
||||
}
|
||||
if len(cmdArgs.Targets) > 0 {
|
||||
return handleYogurt(alpmHandle, cmdArgs)
|
||||
return handleYogurt(cmdArgs, alpmHandle)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func handleGetpkgbuild(alpmHandle *alpm.Handle, cmdArgs *settings.Arguments) error {
|
||||
func handleGetpkgbuild(cmdArgs *settings.Arguments, alpmHandle *alpm.Handle) error {
|
||||
return getPkgbuilds(cmdArgs.Targets, alpmHandle, cmdArgs.ExistsArg("f", "force"))
|
||||
}
|
||||
|
||||
func handleYogurt(alpmHandle *alpm.Handle, cmdArgs *settings.Arguments) error {
|
||||
func handleYogurt(cmdArgs *settings.Arguments, alpmHandle *alpm.Handle) error {
|
||||
config.SearchMode = numberMenu
|
||||
return displayNumberMenu(cmdArgs.Targets, alpmHandle, cmdArgs)
|
||||
}
|
||||
|
||||
func handleSync(alpmHandle *alpm.Handle, cmdArgs *settings.Arguments) error {
|
||||
func handleSync(cmdArgs *settings.Arguments, alpmHandle *alpm.Handle) error {
|
||||
targets := cmdArgs.Targets
|
||||
|
||||
if cmdArgs.ExistsArg("s", "search") {
|
||||
@ -269,7 +269,7 @@ func handleSync(alpmHandle *alpm.Handle, cmdArgs *settings.Arguments) error {
|
||||
return show(passToPacman(cmdArgs))
|
||||
}
|
||||
if cmdArgs.ExistsArg("i", "info") {
|
||||
return syncInfo(targets, alpmHandle, cmdArgs)
|
||||
return syncInfo(cmdArgs, targets, alpmHandle)
|
||||
}
|
||||
if cmdArgs.ExistsArg("u", "sysupgrade") {
|
||||
return install(cmdArgs, alpmHandle, false)
|
||||
|
@ -382,7 +382,7 @@ func install(cmdArgs *settings.Arguments, alpmHandle *alpm.Handle, ignoreProvide
|
||||
return err
|
||||
}
|
||||
|
||||
err = buildInstallPkgbuilds(dp, do, srcinfos, cmdArgs, incompatible, conflicts, alpmHandle)
|
||||
err = buildInstallPkgbuilds(cmdArgs, alpmHandle, dp, do, srcinfos, incompatible, conflicts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -947,13 +947,14 @@ func downloadPkgbuildsSources(bases []Base, incompatible stringset.StringSet) (e
|
||||
}
|
||||
|
||||
func buildInstallPkgbuilds(
|
||||
cmdArgs *settings.Arguments,
|
||||
alpmHandle *alpm.Handle,
|
||||
dp *depPool,
|
||||
do *depOrder,
|
||||
srcinfos map[string]*gosrc.Srcinfo,
|
||||
cmdArgs *settings.Arguments,
|
||||
incompatible stringset.StringSet,
|
||||
conflicts stringset.MapStringSet,
|
||||
alpmHandle *alpm.Handle) error {
|
||||
) error {
|
||||
arguments := cmdArgs.Copy()
|
||||
arguments.ClearTargets()
|
||||
arguments.Op = "U"
|
||||
|
6
main.go
6
main.go
@ -74,7 +74,7 @@ func initBuildDir() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func initAlpm(pacmanConfigPath string, cmdArgs *settings.Arguments) (*alpm.Handle, *pacmanconf.Config, error) {
|
||||
func initAlpm(cmdArgs *settings.Arguments, pacmanConfigPath string) (*alpm.Handle, *pacmanconf.Config, error) {
|
||||
root := "/"
|
||||
if value, _, exists := cmdArgs.GetArg("root", "r"); exists {
|
||||
root = value
|
||||
@ -196,8 +196,8 @@ func main() {
|
||||
config.ExpandEnv()
|
||||
exitOnError(initBuildDir())
|
||||
exitOnError(initVCS(runtime.VCSPath))
|
||||
config.Runtime.AlpmHandle, config.Runtime.PacmanConf, err = initAlpm(config.PacmanConf, cmdArgs)
|
||||
config.Runtime.AlpmHandle, config.Runtime.PacmanConf, err = initAlpm(cmdArgs, config.PacmanConf)
|
||||
exitOnError(err)
|
||||
exitOnError(handleCmd(config.Runtime.AlpmHandle, cmdArgs))
|
||||
exitOnError(handleCmd(cmdArgs, config.Runtime.AlpmHandle))
|
||||
os.Exit(cleanup(config.Runtime.AlpmHandle))
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func TestInitAlpm(t *testing.T) {
|
||||
alpmHandle, pacmanConf, err := initAlpm("testdata/pacman.conf", settings.MakeArguments())
|
||||
alpmHandle, pacmanConf, err := initAlpm(settings.MakeArguments(), "testdata/pacman.conf")
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, pacmanConf)
|
||||
|
||||
|
2
query.go
2
query.go
@ -198,7 +198,7 @@ func syncSearch(pkgS []string, alpmHandle *alpm.Handle) (err error) {
|
||||
}
|
||||
|
||||
// SyncInfo serves as a pacman -Si for repo packages and AUR packages.
|
||||
func syncInfo(pkgS []string, alpmHandle *alpm.Handle, cmdArgs *settings.Arguments) error {
|
||||
func syncInfo(cmdArgs *settings.Arguments, pkgS []string, alpmHandle *alpm.Handle) error {
|
||||
var info []*rpc.Pkg
|
||||
missing := false
|
||||
pkgS = removeInvalidTargets(pkgS)
|
||||
|
Loading…
Reference in New Issue
Block a user