From 4a77d1764aabb854b0ed873180461fe7b25f8a36 Mon Sep 17 00:00:00 2001 From: kitsunyan Date: Sun, 6 May 2018 01:26:16 +0300 Subject: Filter necessary arguments only --- src/common.nim | 2 +- src/feature/syncinstall.nim | 5 ++++- src/pacman.nim | 22 ++-------------------- 3 files changed, 7 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/common.nim b/src/common.nim index b00b482..daa7897 100644 --- a/src/common.nim +++ b/src/common.nim @@ -37,7 +37,7 @@ proc checkAndRefresh*(color: bool, args: seq[Argument]): tuple[code: int, args: let refreshCount = args.count(%%%"refresh") if refreshCount > 0: let code = pacmanRun(true, color, args - .keepOnlyOptions(commonOptions, upgradeCommonOptions) & + .keepOnlyOptions(commonOptions, transactionOptions, upgradeOptions) & ("S", none(string), ArgumentType.short) & ("y", none(string), ArgumentType.short).repeat(refreshCount)) diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim index 3b61eea..89fc90c 100644 --- a/src/feature/syncinstall.nim +++ b/src/feature/syncinstall.nim @@ -738,7 +738,10 @@ proc handleInstall(args: seq[Argument], config: Config, upgradeCount: int, clearPaths(initialPaths) directCode else: - let commonArgs = args.keepOnlyOptions(commonOptions, upgradeCommonOptions) + let commonArgs = args + .keepOnlyOptions(commonOptions, transactionOptions, upgradeOptions) + .filter(true, false, %%%"asdeps", %%%"asexplicit", %%%"needed") + let (resolveSuccess, satisfied, additionalPacmanTargets, basePackages, dependencyPaths) = resolveDependencies(config, pkgInfos, additionalPkgInfos, false, directSome, noaur) let paths = initialPaths & dependencyPaths 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 -- cgit v1.2.3-70-g09d2