diff options
author | kitsunyan | 2018-04-29 13:44:59 +0000 |
---|---|---|
committer | kitsunyan | 2018-04-29 13:44:59 +0000 |
commit | 9525d77603309b81faa43b14137b0a48f7391850 (patch) | |
tree | 3d8d2ec858681606c2ec5b5228529208dda91039 /src/feature | |
parent | 34fb7795b12ad3aade4905438f44c9be95d9d501 (diff) |
Simplify arguments checking
Diffstat (limited to 'src/feature')
-rw-r--r-- | src/feature/localquery.nim | 4 | ||||
-rw-r--r-- | src/feature/syncinstall.nim | 23 | ||||
-rw-r--r-- | src/feature/syncsearch.nim | 2 |
3 files changed, 14 insertions, 15 deletions
diff --git a/src/feature/localquery.nim b/src/feature/localquery.nim index f4142ee..ccc1311 100644 --- a/src/feature/localquery.nim +++ b/src/feature/localquery.nim @@ -20,8 +20,8 @@ proc handleQueryOrphans*(args: seq[Argument], config: Config): int = if results.len > 0: let newArgs = args.filter(arg => not arg.isTarget and - not arg.matchOption((some("t"), "unrequired")) and - not arg.matchOption((some("d"), "deps"))) & + not arg.matchOption(%%%"unrequired") and + not arg.matchOption(%%%"deps")) & results.map(r => (r, none(string), ArgumentType.target)) pacmanExec(false, config.color, newArgs) elif targets.len == 0: diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim index 81177ea..c214198 100644 --- a/src/feature/syncinstall.nim +++ b/src/feature/syncinstall.nim @@ -1242,22 +1242,21 @@ proc resolveBuildTargets(config: Config, targets: seq[PackageTarget], proc handleSyncInstall*(args: seq[Argument], config: Config): int = let (_, callArgs) = checkAndRefresh(config.color, args) - let upgradeCount = args.count((some("u"), "sysupgrade")) - let needed = args.check((none(string), "needed")) - let noaur = args.check((none(string), "noaur")) - let build = args.check((none(string), "build")) - - let printModeArg = args.check((some("p"), "print")) - let printModeFormat = args.filter(arg => arg - .matchOption((none(string), "print-format"))).optLast + let upgradeCount = args.count(%%%"sysupgrade") + let needed = args.check(%%%"needed") + let noaur = args.check(%%%"noaur") + let build = args.check(%%%"build") + + let printModeArg = args.check(%%%"print") + let printModeFormat = args.filter(arg => arg.matchOption(%%%"print-format")).optLast let printFormat = if printModeArg or printModeFormat.isSome: some(printModeFormat.map(arg => arg.value.get).get("%l")) else: none(string) let noconfirm = args - .filter(arg => arg.matchOption((none(string), "confirm")) or - arg.matchOption((none(string), "noconfirm"))).optLast + .filter(arg => arg.matchOption(%%%"confirm") or + arg.matchOption(%%%"noconfirm")).optLast .map(arg => arg.key == "noconfirm").get(false) let targets = args.packageTargets @@ -1281,9 +1280,9 @@ proc handleSyncInstall*(args: seq[Argument], config: Config): int = .filter(i => not i.explicit).map(i => i.name).toSet let keepNames = foreignExplicitsNamesSet + foreignDepsNamesSet + targetNamesSet - let explicits = if args.check((none(string), "asexplicit")): + let explicits = if args.check(%%%"asexplicit"): targetNamesSet + foreignExplicitsNamesSet + foreignDepsNamesSet - elif args.check((none(string), "asdeps")): + elif args.check(%%%"asdeps"): initSet[string]() else: foreignExplicitsNamesSet + (targetNamesSet - foreignDepsNamesSet) diff --git a/src/feature/syncsearch.nim b/src/feature/syncsearch.nim index 7b2e77c..178a839 100644 --- a/src/feature/syncsearch.nim +++ b/src/feature/syncsearch.nim @@ -7,7 +7,7 @@ import proc handleSyncSearch*(args: seq[Argument], config: Config): int = let (_, callArgs) = checkAndRefresh(config.color, args) - let quiet = args.check((some("q"), "quiet")) + let quiet = args.check(%%%"quiet") let (aurPackages, aerrors) = findAurPackages(args.targets) for e in aerrors: printError(config.color, e) |