diff options
author | kitsunyan | 2018-05-05 22:26:16 +0000 |
---|---|---|
committer | kitsunyan | 2018-05-05 22:26:16 +0000 |
commit | 4a77d1764aabb854b0ed873180461fe7b25f8a36 (patch) | |
tree | 4f6e7b9e7390d8864faf2626981b0151cf7b78b6 /src/pacman.nim | |
parent | b4f8782ab5ca934dac8f1c6dad52fbb3755dc005 (diff) |
Filter necessary arguments only
Diffstat (limited to 'src/pacman.nim')
-rw-r--r-- | src/pacman.nim | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/src/pacman.nim b/src/pacman.nim index 4c55f8e..25833ee 100644 --- a/src/pacman.nim +++ b/src/pacman.nim @@ -162,11 +162,6 @@ const o("machinereadable") ] - upgradeCommonOptions*: seq[CommandOption] = @[ - o("noprogressbar"), - o("force") - ] - allOptions* = commonOptions & transactionOptions & upgradeOptions & queryOptions & removeOptions & syncOptions & databaseOptions & filesOptions @@ -184,19 +179,6 @@ const allConflictingOptions = syncConflictingOptions -proc checkOptions(check: seq[CommandOption], - where: openArray[seq[CommandOption]]) {.compileTime.} = - let whereSeq = @where - let whereSet = lc[x.pair | (y <- whereSeq, x <- y), OptionPair].toSet - for c in check: - if not (c.pair in whereSet): - raise newException(SystemError, - "invalid options definition: " & $c.pair) - -static: - # options test - checkOptions(upgradeCommonOptions, [commonOptions, transactionOptions, upgradeOptions]) - proc getOperation*(args: seq[Argument]): OperationType = let matchedOps = args .map(arg => operations @@ -212,11 +194,11 @@ proc getOperation*(args: seq[Argument]): OperationType = OperationType.invalid proc filterOptions*(args: seq[Argument], removeMatches: bool, keepTargets: bool, - includeOptions: bool, opts: varargs[seq[CommandOption]]): seq[Argument] = + includeOperations: bool, opts: varargs[seq[CommandOption]]): seq[Argument] = let optsSeq = @opts let optsPairSeq = lc[x.pair | (y <- optsSeq, x <- y), OptionPair] - let work = if includeOptions: + let work = if includeOperations: (optsPairSeq & operations.map(o => o.pair)) else: optsPairSeq |