Make shit less ass fuck shit fuck ass shit ass bruh what is this code

This commit is contained in:
2026-06-06 19:00:37 +03:00
parent 202f6d42ac
commit 4d6dbadc32
87 changed files with 1497 additions and 954 deletions
+12 -17
View File
@@ -1,28 +1,23 @@
-- TODO: Rename this to something else (while making an alias from the original command).
-- Touch seems kind of a silly name for a command to make a file.
-- Maybe something like mkfile would be better?
local cliparse = require("cliparse")
cliparse.config({
["o"] = 0,
["overwrite"] = 0,
})
local parsed = cliparse.parse(...)
local file = parsed.args[1]
local fs = require("filesystem")
local shell = require("shell")
if not file then
local args = {...}
if not args[1] then
return shell.run("help touch")
end
if file:sub(1, 1) ~= "/" then
file = fs.concat(shell.getWorkingDirectory(), file)
end
for _, file in pairs(args) do
file = shell.resolvePath(file)
if fs.exists(file) and not (parsed.flags.o or parsed.flags.overwrite) then
return print("\x1b[91mFile already exists.\n│ To empty file contents, use -o.")
local handle, err = fs.open(file, "a")
if err ~= nil then
terminal.write("\27[91mError: " .. err .. "\27[0m\n")
goto continue
end
handle:close()
::continue::
end
local handle = fs.open(file, "w")
handle:write("") -- just in case
handle:close()