From 5042d48a85fce3721d4e9b8c0ab1a0239d68a004 Mon Sep 17 00:00:00 2001 From: XDuskAshesReal <101196233+XDuskAshes@users.noreply.github.com> Date: Fri, 26 Apr 2024 18:36:29 -0400 Subject: [PATCH] [NEW] EOF handling Handles end-of-files by requiring a comment ('--') be made to denote end-of-file. This end-of-file denoter does not get included in the final file. --- stitch.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/stitch.lua b/stitch.lua index b6316ca..fcfafed 100644 --- a/stitch.lua +++ b/stitch.lua @@ -4,6 +4,12 @@ local args = {...} +if args[1] == "--help" or args[1] == "-h" or args[1] == "-?" then + print("stitch | Cobbles files together efficiently.*") + print("--------------------------------------------") + print("--help/-h/-? | Show this help.") +end + local function e(s) return s == "" or s == nil end @@ -51,7 +57,7 @@ handle.close() handle = fs.open(args[1],"r") -repeat +repeat local a = handle.readLine() table.insert(instructions,a) until e(a) @@ -61,14 +67,16 @@ handle.close() for k,v in pairs(instructions) do print(k,v) local toWrite = {} - + handle = fs.open(v,"r") - repeat + repeat local a = handle.readLine() table.insert(toWrite,a) - until a == nil + until a == "--" handle.close() + table.remove(toWrite,#toWrite) + handle = fs.open(args[2],"a") for k,v in pairs(toWrite) do handle.writeLine(v)