aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/feature/syncinfo.nim43
-rw-r--r--src/feature/syncinstall.nim98
-rw-r--r--src/feature/syncsearch.nim78
-rw-r--r--src/feature/syncsource.nim44
4 files changed, 136 insertions, 127 deletions
diff --git a/src/feature/syncinfo.nim b/src/feature/syncinfo.nim
index fc1510b..2de5bda 100644
--- a/src/feature/syncinfo.nim
+++ b/src/feature/syncinfo.nim
@@ -100,29 +100,32 @@ proc handleTarget(config: Config, padding: int, args: seq[Argument],
pacmanRun(false, config.color, args & ($target, none(string), ArgumentType.target))
proc handleSyncInfo*(args: seq[Argument], config: Config): int =
- let (_, callArgs) = checkAndRefresh(config.color, args)
- let targets = args.packageTargets(false)
+ let (refreshCode, callArgs) = checkAndRefresh(config.color, args)
+ if refreshCode != 0:
+ refreshCode
+ else:
+ let targets = args.packageTargets(false)
- let (syncTargets, checkAurNames) = withAlpmConfig(config, true, handle, dbs, errors):
- for e in errors: printError(config.color, e)
- findSyncTargets(handle, dbs, targets, false, false)
+ let (syncTargets, checkAurNames) = withAlpmConfig(config, true, handle, dbs, errors):
+ for e in errors: printError(config.color, e)
+ findSyncTargets(handle, dbs, targets, false, false)
- let (pkgInfos, _, aerrors) = getAurPackageInfos(checkAurNames, config.arch)
- for e in aerrors: printError(config.color, e)
+ let (pkgInfos, _, aerrors) = getAurPackageInfos(checkAurNames, config.arch)
+ for e in aerrors: printError(config.color, e)
- let fullTargets = mapAurTargets[PackageInfo](syncTargets, pkgInfos)
+ let fullTargets = mapAurTargets[PackageInfo](syncTargets, pkgInfos)
- let code = min(aerrors.len, 1)
- if fullTargets.filter(t => isAurTargetFull[PackageInfo](t) or t.repo == some("aur")).len == 0 and
- fullTargets.filter(t => t.reference.constraint.isSome).len == 0:
- if code == 0:
- pacmanExec(false, config.color, callArgs)
+ let code = min(aerrors.len, 1)
+ if fullTargets.filter(t => isAurTargetFull[PackageInfo](t) or t.repo == some("aur") or
+ t.reference.constraint.isSome).len == 0:
+ if code == 0:
+ pacmanExec(false, config.color, callArgs)
+ else:
+ discard pacmanRun(false, config.color, callArgs)
+ code
else:
- discard pacmanRun(false, config.color, callArgs)
- code
- else:
- let finalArgs = callArgs.filter(arg => not arg.isTarget)
- let padding = pacmanInfoStrings.map(s => s.trp).computeMaxLength
+ let finalArgs = callArgs.filter(arg => not arg.isTarget)
+ let padding = pacmanInfoStrings.map(s => s.trp).computeMaxLength
- let codes = code & lc[handleTarget(config, padding, finalArgs, x) | (x <- fullTargets), int]
- codes.filter(c => c != 0).optFirst.get(0)
+ let codes = code & lc[handleTarget(config, padding, finalArgs, x) | (x <- fullTargets), int]
+ codes.filter(c => c != 0).optFirst.get(0)
diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim
index 4bb3837..1ca1083 100644
--- a/src/feature/syncinstall.nim
+++ b/src/feature/syncinstall.nim
@@ -1307,53 +1307,55 @@ proc resolveBuildTargets(config: Config, targets: seq[PackageTarget],
finalPkgInfos, additionalPkgInfos, buildPaths & aurPaths)
proc handleSyncInstall*(args: seq[Argument], config: Config): int =
- let (_, callArgs) = checkAndRefresh(config.color, args)
-
- let upgradeCount = args.count(%%%"sysupgrade")
- let nodepsCount = args.count(%%%"nodeps")
- let needed = args.check(%%%"needed")
- let noaur = args.check(%%%"noaur")
- let build = args.check(%%%"build")
-
- let printModeArg = args.check(%%%"print")
- let printModeFormat = args.filter(arg => arg.matchOption(%%%"print-format")).optLast
- let printFormat = if printModeArg or printModeFormat.isSome:
- some(printModeFormat.map(arg => arg.value.get).get("%l"))
- else:
- none(string)
+ let (refreshCode, callArgs) = checkAndRefresh(config.color, args)
+ if refreshCode != 0:
+ refreshCode
+ else:
+ let upgradeCount = args.count(%%%"sysupgrade")
+ let nodepsCount = args.count(%%%"nodeps")
+ let needed = args.check(%%%"needed")
+ let noaur = args.check(%%%"noaur")
+ let build = args.check(%%%"build")
+
+ let printModeArg = args.check(%%%"print")
+ let printModeFormat = args.filter(arg => arg.matchOption(%%%"print-format")).optLast
+ let printFormat = if printModeArg or printModeFormat.isSome:
+ some(printModeFormat.map(arg => arg.value.get).get("%l"))
+ else:
+ none(string)
- let noconfirm = args
- .filter(arg => arg.matchOption(%%%"confirm") or
- arg.matchOption(%%%"noconfirm")).optLast
- .map(arg => arg.key == "noconfirm").get(false) or
- args.check(%%%"ask")
-
- let targets = args.packageTargets(false)
-
- withAur():
- let (code, installed, targetNamesSet, pacmanTargets,
- pkgInfos, additionalPkgInfos, paths) = resolveBuildTargets(config, targets,
- printFormat.isSome, upgradeCount, noconfirm, needed, noaur, build)
-
- let pacmanArgs = callArgs.filterExtensions(true, true,
- commonOptions, transactionOptions, upgradeOptions, syncOptions)
- if code != 0:
- code
- elif printFormat.isSome:
- handlePrint(pacmanArgs, config, printFormat.unsafeGet, upgradeCount, nodepsCount,
- pacmanTargets, pkgInfos, additionalPkgInfos, noaur)
- else:
- let explicitsNamesSet = installed.filter(i => i.explicit).map(i => i.name).toSet
- let depsNamesSet = installed.filter(i => not i.explicit).map(i => i.name).toSet
- let keepNames = explicitsNamesSet + depsNamesSet + targetNamesSet
-
- let explicits = if args.check(%%%"asexplicit"):
- targetNamesSet + explicitsNamesSet + depsNamesSet
- elif args.check(%%%"asdeps"):
- initSet[string]()
- else:
- explicitsNamesSet + (targetNamesSet - depsNamesSet)
+ let noconfirm = args
+ .filter(arg => arg.matchOption(%%%"confirm") or
+ arg.matchOption(%%%"noconfirm")).optLast
+ .map(arg => arg.key == "noconfirm").get(false) or
+ args.check(%%%"ask")
+
+ let targets = args.packageTargets(false)
+
+ withAur():
+ let (code, installed, targetNamesSet, pacmanTargets,
+ pkgInfos, additionalPkgInfos, paths) = resolveBuildTargets(config, targets,
+ printFormat.isSome, upgradeCount, noconfirm, needed, noaur, build)
+
+ let pacmanArgs = callArgs.filterExtensions(true, true,
+ commonOptions, transactionOptions, upgradeOptions, syncOptions)
+ if code != 0:
+ code
+ elif printFormat.isSome:
+ handlePrint(pacmanArgs, config, printFormat.unsafeGet, upgradeCount, nodepsCount,
+ pacmanTargets, pkgInfos, additionalPkgInfos, noaur)
+ else:
+ let explicitsNamesSet = installed.filter(i => i.explicit).map(i => i.name).toSet
+ let depsNamesSet = installed.filter(i => not i.explicit).map(i => i.name).toSet
+ let keepNames = explicitsNamesSet + depsNamesSet + targetNamesSet
+
+ let explicits = if args.check(%%%"asexplicit"):
+ targetNamesSet + explicitsNamesSet + depsNamesSet
+ elif args.check(%%%"asdeps"):
+ initSet[string]()
+ else:
+ explicitsNamesSet + (targetNamesSet - depsNamesSet)
- handleInstall(pacmanArgs, config, upgradeCount, nodepsCount, noconfirm,
- explicits, installed, pacmanTargets, pkgInfos, additionalPkgInfos, keepNames,
- paths, build, noaur)
+ handleInstall(pacmanArgs, config, upgradeCount, nodepsCount, noconfirm,
+ explicits, installed, pacmanTargets, pkgInfos, additionalPkgInfos, keepNames,
+ paths, build, noaur)
diff --git a/src/feature/syncsearch.nim b/src/feature/syncsearch.nim
index 4d0eb50..0b1aeae 100644
--- a/src/feature/syncsearch.nim
+++ b/src/feature/syncsearch.nim
@@ -5,49 +5,51 @@ import
"../wrapper/alpm"
proc handleSyncSearch*(args: seq[Argument], config: Config): int =
- let (_, callArgs) = checkAndRefresh(config.color, args)
-
- let quiet = args.check(%%%"quiet")
-
- let (aurPackages, aerrors) = findAurPackages(args.targets)
- for e in aerrors: printError(config.color, e)
+ let (refreshCode, callArgs) = checkAndRefresh(config.color, args)
+ if refreshCode != 0:
+ refreshCode
+ else:
+ let quiet = args.check(%%%"quiet")
- type Package = tuple[rpcInfo: RpcPackageInfo, installedVersion: Option[string]]
+ let (aurPackages, aerrors) = findAurPackages(args.targets)
+ for e in aerrors: printError(config.color, e)
- proc checkLocalPackages: seq[Package] =
- if quiet:
- aurPackages.map(pkg => (pkg, none(string)))
- elif aurPackages.len > 0:
- withAlpmConfig(config, false, handle, dbs, errors):
- for e in errors: printError(config.color, e)
+ type Package = tuple[rpcInfo: RpcPackageInfo, installedVersion: Option[string]]
- aurPackages.map(proc (rpcInfo: RpcPackageInfo): Package =
- let pkg = handle.local[rpcInfo.name]
- if pkg != nil:
- (rpcInfo, some($pkg.version))
- else:
- (rpcInfo, none(string)))
- else:
- @[]
+ proc checkLocalPackages: seq[Package] =
+ if quiet:
+ aurPackages.map(pkg => (pkg, none(string)))
+ elif aurPackages.len > 0:
+ withAlpmConfig(config, false, handle, dbs, errors):
+ for e in errors: printError(config.color, e)
+
+ aurPackages.map(proc (rpcInfo: RpcPackageInfo): Package =
+ let pkg = handle.local[rpcInfo.name]
+ if pkg != nil:
+ (rpcInfo, some($pkg.version))
+ else:
+ (rpcInfo, none(string)))
+ else:
+ @[]
- let pkgs = checkLocalPackages()
- .sorted((a, b) => cmp(a.rpcInfo.name, b.rpcInfo.name))
+ let pkgs = checkLocalPackages()
+ .sorted((a, b) => cmp(a.rpcInfo.name, b.rpcInfo.name))
- var code = min(aerrors.len, 1)
- if pkgs.len == 0:
- if code == 0:
- pacmanExec(false, config.color, callArgs)
+ var code = min(aerrors.len, 1)
+ if pkgs.len == 0:
+ if code == 0:
+ pacmanExec(false, config.color, callArgs)
+ else:
+ discard pacmanRun(false, config.color, callArgs)
+ code
else:
discard pacmanRun(false, config.color, callArgs)
- code
- else:
- discard pacmanRun(false, config.color, callArgs)
- for pkg in pkgs:
- if quiet:
- echo(pkg.rpcInfo.name)
- else:
- printPackageSearch(config.color, "aur", pkg.rpcInfo.name,
- pkg.rpcInfo.version, pkg.installedVersion, pkg.rpcInfo.description,
- some(formatPkgRating(pkg.rpcInfo.votes, pkg.rpcInfo.popularity)))
- 0
+ for pkg in pkgs:
+ if quiet:
+ echo(pkg.rpcInfo.name)
+ else:
+ printPackageSearch(config.color, "aur", pkg.rpcInfo.name,
+ pkg.rpcInfo.version, pkg.installedVersion, pkg.rpcInfo.description,
+ some(formatPkgRating(pkg.rpcInfo.votes, pkg.rpcInfo.popularity)))
+ 0
diff --git a/src/feature/syncsource.nim b/src/feature/syncsource.nim
index 8096f02..5c3f35a 100644
--- a/src/feature/syncsource.nim
+++ b/src/feature/syncsource.nim
@@ -153,28 +153,30 @@ proc cloneAndCopy(config: Config, quiet: bool,
0
proc handleSyncSource*(args: seq[Argument], config: Config): int =
- discard checkAndRefresh(config.color, args)
-
- let quiet = args.check(%%%"quiet")
- let targets = args.packageTargets(true)
-
- if targets.len == 0:
- printError(config.color, trp("no targets specified (use -h for help)\n"))
- 1
+ let (refreshCode, _) = checkAndRefresh(config.color, args)
+ if refreshCode != 0:
+ refreshCode
else:
- let (syncTargets, checkAurNames) = withAlpmConfig(config, true, handle, dbs, errors):
- for e in errors: printError(config.color, e)
- findSyncTargets(handle, dbs, targets, false, false)
-
- let (rpcInfos, aerrors) = getRpcPackageInfos(checkAurNames)
- for e in aerrors: printError(config.color, e)
-
- let notFoundTargets = filterNotFoundSyncTargets(syncTargets,
- rpcInfos, initTable[string, PackageReference]())
+ let quiet = args.check(%%%"quiet")
+ let targets = args.packageTargets(true)
- if notFoundTargets.len > 0:
- printSyncNotFound(config, notFoundTargets)
+ if targets.len == 0:
+ printError(config.color, trp("no targets specified (use -h for help)\n"))
1
else:
- let fullTargets = mapAurTargets[RpcPackageInfo](syncTargets, rpcInfos)
- cloneAndCopy(config, quiet, fullTargets)
+ let (syncTargets, checkAurNames) = withAlpmConfig(config, true, handle, dbs, errors):
+ for e in errors: printError(config.color, e)
+ findSyncTargets(handle, dbs, targets, false, false)
+
+ let (rpcInfos, aerrors) = getRpcPackageInfos(checkAurNames)
+ for e in aerrors: printError(config.color, e)
+
+ let notFoundTargets = filterNotFoundSyncTargets(syncTargets,
+ rpcInfos, initTable[string, PackageReference]())
+
+ if notFoundTargets.len > 0:
+ printSyncNotFound(config, notFoundTargets)
+ 1
+ else:
+ let fullTargets = mapAurTargets[RpcPackageInfo](syncTargets, rpcInfos)
+ cloneAndCopy(config, quiet, fullTargets)