aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--USAGE.txt7
-rw-r--r--src/tmachines.nim (renamed from src/tm.nim)15
-rw-r--r--src/tmachinespkg/lib.nim (renamed from src/lib.nim)0
-rw-r--r--src/tmachinespkg/mt.nim (renamed from src/mt.nim)0
4 files changed, 16 insertions, 6 deletions
diff --git a/USAGE.txt b/USAGE.txt
new file mode 100644
index 0000000..d8fb8e0
--- /dev/null
+++ b/USAGE.txt
@@ -0,0 +1,7 @@
+TMachine: a Turing machine emulator.
+
+Usage: tmachines [options] <machine> <input>
+
+Options:
+ -q --quiet Only output "true" or "false"
+ -h --help Show this help message.
diff --git a/src/tm.nim b/src/tmachines.nim
index 26c97f2..d89980e 100644
--- a/src/tm.nim
+++ b/src/tmachines.nim
@@ -1,6 +1,8 @@
import os
-import lib
+import docopt
+
+import tmachinespkg/lib
const tmname {.strdefine.}: string = ""
@@ -11,8 +13,9 @@ when tmname.len > 0:
else:
echo "please specify a single string argument"
else:
- if paramCount() >= 2:
- let tmd = parse(readFile(paramStr(1) & ".tm"))
- echo makeDTM(tmd, paramStr(2)).test(true)
- else:
- echo "please specify a description and string input"
+ const doc = slurp("../USAGE.txt")
+
+ let args = docopt(doc)
+
+ let tmd = parse(readFile($args["<machine>"] & ".tm"))
+ echo makeDTM(tmd, $args["<input>"]).test(not args["--quiet"])
diff --git a/src/lib.nim b/src/tmachinespkg/lib.nim
index b909478..b909478 100644
--- a/src/lib.nim
+++ b/src/tmachinespkg/lib.nim
diff --git a/src/mt.nim b/src/tmachinespkg/mt.nim
index 8055921..8055921 100644
--- a/src/mt.nim
+++ b/src/tmachinespkg/mt.nim