diff options
author | Benjamin Shirley-Quirk | 2020-08-05 01:14:46 +0000 |
---|---|---|
committer | Benjamin Shirley-Quirk | 2020-08-05 01:14:46 +0000 |
commit | 4bbf3dc2097f1de206fa053fac32f675d4ae2927 (patch) | |
tree | 721da2b78793860b6fb020194efe2eccea88bac9 /src/args.nim | |
parent | cb63408d7d9de91020a7a815216b531fdf944b47 (diff) |
factored out unnecessary NimVersions
Diffstat (limited to 'src/args.nim')
-rw-r--r-- | src/args.nim | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/src/args.nim b/src/args.nim index b93d5fb..cd778f6 100644 --- a/src/args.nim +++ b/src/args.nim @@ -104,13 +104,10 @@ proc splitArgs*(params: seq[string], let argsResult = toSeq(splitSingle(current[1 .. ^1], optionsWithParameter, next)) let consumedNext = argsResult.map(a => a.consumedNext).foldl(a or b) let newNext = next.filter(n => not consumedNext) - when NimVersion >= "1.2": - return((block:collect(newSeq): - for x in argsResult: - (x.key,x.value,ArgumentType.short) - ), newNext, stdinConsumed, false) - else: - return (lc[(x.key, x.value, ArgumentType.short) | (x <- argsResult), Argument], newNext, stdinConsumed, false) + return((block:collect(newSeq): + for x in argsResult: + (x.key,x.value,ArgumentType.short) + ), newNext, stdinConsumed, false) else: return (@[(current, none(string), ArgumentType.target)], next, stdinConsumed, false) @@ -143,13 +140,10 @@ proc splitArgs*(params: seq[string], discard close(0) discard open("/dev/tty", O_RDONLY) - when NimVersion >= "1.2": - collect(newSeq): - for y in cycle.args: - for x in y.arg: - x - else: - lc[x | (y <- cycle.args, x <- y.arg), Argument] + collect(newSeq): + for y in cycle.args: + for x in y.arg: + x proc isShort*(arg: Argument): bool = arg.atype == ArgumentType.short proc isLong*(arg: Argument): bool = arg.atype == ArgumentType.long @@ -178,13 +172,10 @@ iterator items*(op: OptionPair): OptionKey = proc filter*(args: seq[Argument], removeMatches: bool, keepTargets: bool, pairs: varargs[OptionPair]): seq[Argument] = let pairsSeq = @pairs - when NimVersion >= "1.2": - let argsSet = collect(initHashSet): - for y in pairsSeq: - for x in y: - {x} - else: - let argsSet = lc[x | (y <- pairsSeq, x <- y), OptionKey].toHashSet + let argsSet = collect(initHashSet): + for y in pairsSeq: + for x in y: + {x} args.filter(arg => (arg.isShort and (removeMatches xor (arg.key, false) in argsSet)) or (arg.isLong and (removeMatches xor (arg.key, true) in argsSet)) or (arg.isTarget and keepTargets)) |