aboutsummaryrefslogtreecommitdiff
path: root/src/common.nim
diff options
context:
space:
mode:
authorkitsunyan2018-06-16 20:20:35 +0000
committerkitsunyan2018-06-16 20:20:35 +0000
commitd25443be575c5d57001cc267be69bb44b6502b72 (patch)
treed26ff374441f715a3ffe7bd63698c0e3ac6eb73a /src/common.nim
parent851291dfd9249b065bac66172dbb37abf19dfb26 (diff)
Resolve AUR upgrades and print warnings after "--sysupgrade"
Diffstat (limited to 'src/common.nim')
-rw-r--r--src/common.nim20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/common.nim b/src/common.nim
index f2fb155..ead9b4b 100644
--- a/src/common.nim
+++ b/src/common.nim
@@ -39,20 +39,32 @@ type
repo: string
]
-proc checkAndRefresh*(color: bool, args: seq[Argument]): tuple[code: int, args: seq[Argument]] =
+proc checkAndRefreshUpgradeInternal(color: bool, upgrade: bool, args: seq[Argument]):
+ tuple[code: int, args: seq[Argument]] =
let refreshCount = args.count(%%%"refresh")
- if refreshCount > 0:
+ let upgradeCount = if upgrade: args.count(%%%"sysupgrade") else: 0
+ if refreshCount > 0 or upgradeCount > 0:
let code = pacmanRun(true, color, args
.keepOnlyOptions(commonOptions, transactionOptions, upgradeOptions) &
("S", none(string), ArgumentType.short) &
- ("y", none(string), ArgumentType.short).repeat(refreshCount))
+ ("y", none(string), ArgumentType.short).repeat(refreshCount) &
+ ("u", none(string), ArgumentType.short).repeat(upgradeCount))
let callArgs = args
- .filter(arg => not arg.matchOption(%%%"refresh"))
+ .filter(arg => not arg.matchOption(%%%"refresh") and
+ (upgradeCount == 0 or not arg.matchOption(%%%"sysupgrade")))
(code, callArgs)
else:
(0, args)
+template checkAndRefreshUpgrade*(color: bool, args: seq[Argument]):
+ tuple[code: int, args: seq[Argument]] =
+ checkAndRefreshUpgradeInternal(color, true, args)
+
+template checkAndRefresh*(color: bool, args: seq[Argument]):
+ tuple[code: int, args: seq[Argument]] =
+ checkAndRefreshUpgradeInternal(color, false, args)
+
proc noconfirm*(args: seq[Argument]): bool =
args
.filter(arg => arg.matchOption(%%%"confirm") or