aboutsummaryrefslogtreecommitdiff
path: root/src/pacman.nim
diff options
context:
space:
mode:
authorkitsunyan2018-05-04 13:12:04 +0000
committerkitsunyan2018-05-04 13:12:04 +0000
commit451cc4aca13cb6637b55c527d1e0647d6fffad5b (patch)
tree20dc46b11f90a5dda2cf34721d99e719d9c5da00 /src/pacman.nim
parent9f2cc1571a06685d28f1b8b0becf4406dda4177b (diff)
Fix extended options filter
Diffstat (limited to 'src/pacman.nim')
-rw-r--r--src/pacman.nim13
1 files changed, 10 insertions, 3 deletions
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]] =