diff options
Diffstat (limited to 'src/nimfunge98.nim')
-rw-r--r-- | src/nimfunge98.nim | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/nimfunge98.nim b/src/nimfunge98.nim new file mode 100644 index 0000000..6e6efb9 --- /dev/null +++ b/src/nimfunge98.nim @@ -0,0 +1,44 @@ +import field +import interpreter +import pointer + +import os +import parseopt +import strformat + +proc Usage(i: int = 0) = + let filename = getAppFilename().extractFilename() + echo fmt"""Usage of {filename}: + -f string b98 file to interpret + -h display this help message + """ + if i != 0: + quit i + +var filename: string + +for kind, key, value in getOpt(): + case kind + of cmdArgument: + if filename != "": + echo "Invalid argument: ", key + Usage(1) + filename = key + of cmdLongOption, cmdShortOption: + case key + of "h": + Usage() + else: + echo "Unknown option: ", key + Usage(1) + of cmdEnd: + discard + +var f = Load(filename) +if f == nil: + echo "Failed to load ", filename + quit 1 +let argv = @[filename] +var p = NewPointer(argv=argv) +let v = NewInterpreter(f, p)[].Run() +quit v |