Created
April 23, 2017 17:18
-
-
Save Bennyelg/e80f4c06b90547bdd370f9d2a76a8f93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import strutils | |
import sequtils | |
import os | |
import tables | |
proc parseArguments*(inputString: seq[string]): Table[string, string] = | |
var arguments = newSeq[string]() | |
if inputString.len == 0: | |
discard | |
else: | |
for i in 1..<inputString.len: | |
arguments.add(inputString[i]) | |
var keyValue = initTable[string, string]() | |
for ind, value in arguments: | |
if ind mod 2 == 0: | |
if "-h" in value: | |
echo("Reserved key word. (-h, --help) is not allowed.") | |
quit(0) | |
keyValue[value] = arguments[ind + 1] | |
return keyValue | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment