refactor
This commit is contained in:
parent
612a15fd5e
commit
4004ecb9e0
23
src/main.nim
23
src/main.nim
|
@ -1,31 +1,22 @@
|
|||
import strutils, os, procedures
|
||||
|
||||
var operation: string
|
||||
var argument: string
|
||||
|
||||
if paramCount() > 0:
|
||||
argument = toLowerAscii(paramStr(1))
|
||||
|
||||
#? if command is "dot" or "cross" preform that operation
|
||||
if paramStr(0).endsWith("/dot") or paramStr(0) == "dot" or argument == "dot" or argument == "d":
|
||||
operation = "dot"
|
||||
dot()
|
||||
let args = [paramStr(0).splitPath.tail, paramStr(0), argument]
|
||||
|
||||
elif paramStr(0).endsWith("/cross") or paramStr(0) == "cross" or argument == "cross" or argument == "c":
|
||||
operation = "cross"
|
||||
if "dot" in args or "d" in args:
|
||||
dot()
|
||||
elif "cross" in args or "c" in args:
|
||||
cross()
|
||||
else:
|
||||
echo "Would you like to preform the dot or cross product?"
|
||||
operation = toLowerAscii(readLine(stdin))
|
||||
case operation:
|
||||
of "dot":
|
||||
case toLowerAscii(readLine(stdin)):
|
||||
of "dot", "d":
|
||||
dot()
|
||||
of "d":
|
||||
dot()
|
||||
of "cross":
|
||||
cross()
|
||||
of "c":
|
||||
of "cross", "c":
|
||||
cross()
|
||||
else:
|
||||
quit "Invalid operation!", QuitFailure
|
||||
|
||||
|
|
Loading…
Reference in a new issue