Skip to content

Instantly share code, notes, and snippets.

@Bennyelg
Created April 23, 2017 17:18
Show Gist options
  • Save Bennyelg/e80f4c06b90547bdd370f9d2a76a8f93 to your computer and use it in GitHub Desktop.
Save Bennyelg/e80f4c06b90547bdd370f9d2a76a8f93 to your computer and use it in GitHub Desktop.
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