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
|
import strutils, os, procedures
|
||||||
|
|
||||||
var operation: string
|
|
||||||
var argument: string
|
var argument: string
|
||||||
|
|
||||||
if paramCount() > 0:
|
if paramCount() > 0:
|
||||||
argument = toLowerAscii(paramStr(1))
|
argument = toLowerAscii(paramStr(1))
|
||||||
|
|
||||||
#? if command is "dot" or "cross" preform that operation
|
let args = [paramStr(0).splitPath.tail, paramStr(0), argument]
|
||||||
if paramStr(0).endsWith("/dot") or paramStr(0) == "dot" or argument == "dot" or argument == "d":
|
|
||||||
operation = "dot"
|
|
||||||
dot()
|
|
||||||
|
|
||||||
elif paramStr(0).endsWith("/cross") or paramStr(0) == "cross" or argument == "cross" or argument == "c":
|
if "dot" in args or "d" in args:
|
||||||
operation = "cross"
|
dot()
|
||||||
|
elif "cross" in args or "c" in args:
|
||||||
cross()
|
cross()
|
||||||
else:
|
else:
|
||||||
echo "Would you like to preform the dot or cross product?"
|
echo "Would you like to preform the dot or cross product?"
|
||||||
operation = toLowerAscii(readLine(stdin))
|
case toLowerAscii(readLine(stdin)):
|
||||||
case operation:
|
of "dot", "d":
|
||||||
of "dot":
|
|
||||||
dot()
|
dot()
|
||||||
of "d":
|
of "cross", "c":
|
||||||
dot()
|
|
||||||
of "cross":
|
|
||||||
cross()
|
|
||||||
of "c":
|
|
||||||
cross()
|
cross()
|
||||||
else:
|
else:
|
||||||
quit "Invalid operation!", QuitFailure
|
quit "Invalid operation!", QuitFailure
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue