aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/feature/syncinstall.nim3
-rw-r--r--src/main.nim7
-rw-r--r--src/pacman.nim13
3 files changed, 15 insertions, 8 deletions
diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim
index ec8c064..2677570 100644
--- a/src/feature/syncinstall.nim
+++ b/src/feature/syncinstall.nim
@@ -1233,7 +1233,8 @@ proc handleSyncInstall*(args: seq[Argument], config: Config): int =
pkgInfos, additionalPkgInfos, paths) = resolveBuildTargets(config, targets,
printFormat.isSome, upgradeCount, noconfirm, needed, noaur, build)
- let pacmanArgs = callArgs.filterExtensions(true, true)
+ let pacmanArgs = callArgs.filterExtensions(true, true,
+ commonOptions, transactionOptions, upgradeOptions, syncOptions)
if code != 0:
code
elif printFormat.isSome:
diff --git a/src/main.nim b/src/main.nim
index bf32cdd..52f1cb8 100644
--- a/src/main.nim
+++ b/src/main.nim
@@ -17,9 +17,9 @@ proc passValidation(args: seq[Argument], config: Config,
if checkArgs.len == 0:
let needRoot = (nonRootArgs.len == 0 and args.check(rootArgs)) or
(nonRootArgs.len > 0 and (not args.check(nonRootArgs) or args.check(rootArgs)))
- return pacmanExec(needRoot, config.color, args.filterExtensions(true, true))
+ return pacmanExec(needRoot, config.color, args.filterExtensions(true, true, opts))
else:
- let extensions = args.filterExtensions(false, false)
+ let extensions = args.filterExtensions(false, false, opts)
if extensions.len == 0:
return pacmanExec(false, config.color, args)
else:
@@ -255,8 +255,7 @@ proc run(parsedArgs: seq[Argument], config: Config):
of OperationType.upgrade:
handleUpgrade(parsedArgs, config)
else:
- pacmanExec(false, config.color,
- parsedArgs.filterExtensions(true, true))
+ passValidation(parsedArgs, config, [], [], allOptions)
let runResult = if init.success.isSome:
run(init.success.unsafeGet.parsedArgs, init.success.unsafeGet.config)
diff --git a/src/pacman.nim b/src/pacman.nim
index f9e921c..8415de8 100644
--- a/src/pacman.nim
+++ b/src/pacman.nim
@@ -245,9 +245,16 @@ proc checkOpGroup*(args: seq[Argument], group: OpGroup): bool =
proc `%%%`*(long: string): OptionPair =
allOptions.filter(o => o.pair.long == long)[0].pair
-proc filterExtensions*(args: seq[Argument],
- removeMatches: bool, keepTargets: bool): seq[Argument] =
- let argsSeq = lc[x.pair | (x <- allOptions, x.extension), OptionPair]
+proc filterExtensions*(args: seq[Argument], removeMatches: bool, keepTargets: bool,
+ opts: varargs[seq[CommandOption]]): seq[Argument] =
+ let optsSeq = @opts
+ let optsFilter = if removeMatches:
+ lc[x | (y <- optsSeq, x <- y), CommandOption]
+ else: (block:
+ let pairs = lc[x.pair | (y <- optsSeq, x <- y), OptionPair].toSet
+ lc[x | (x <- allOptions, not (x.pair in pairs)), CommandOption])
+
+ let argsSeq = lc[x.pair | (x <- optsFilter, x.extension), OptionPair]
args.filter(removeMatches, keepTargets, argsSeq)
proc obtainConflictsPairs(conflicts: seq[ConflictingOptions]): Table[string, seq[OptionPair]] =