v1.14.0 - Added the download command (Halyde equivalent of wget) and clipboard pasting support.
This commit is contained in:
+3
-1
@@ -1,7 +1,7 @@
|
|||||||
local agcfg = {
|
local agcfg = {
|
||||||
["halyde"] = {
|
["halyde"] = {
|
||||||
["maindir"] = "",
|
["maindir"] = "",
|
||||||
["version"] = "1.13.0",
|
["version"] = "1.14.0",
|
||||||
["description"] = "A universal, customizable and feature-packed operating system for OpenComputers.",
|
["description"] = "A universal, customizable and feature-packed operating system for OpenComputers.",
|
||||||
["directories"] = {
|
["directories"] = {
|
||||||
"halyde/apps",
|
"halyde/apps",
|
||||||
@@ -20,6 +20,7 @@ local agcfg = {
|
|||||||
"halyde/apps/helpdb/clear.txt",
|
"halyde/apps/helpdb/clear.txt",
|
||||||
"halyde/apps/helpdb/cp.txt",
|
"halyde/apps/helpdb/cp.txt",
|
||||||
"halyde/apps/helpdb/default.txt",
|
"halyde/apps/helpdb/default.txt",
|
||||||
|
"halyde/apps/helpdb/download.txt",
|
||||||
"halyde/apps/helpdb/echo.txt",
|
"halyde/apps/helpdb/echo.txt",
|
||||||
"halyde/apps/helpdb/fetch.txt",
|
"halyde/apps/helpdb/fetch.txt",
|
||||||
"halyde/apps/helpdb/help.txt",
|
"halyde/apps/helpdb/help.txt",
|
||||||
@@ -34,6 +35,7 @@ local agcfg = {
|
|||||||
"halyde/apps/cd.lua",
|
"halyde/apps/cd.lua",
|
||||||
"halyde/apps/clear.lua",
|
"halyde/apps/clear.lua",
|
||||||
"halyde/apps/cp.lua",
|
"halyde/apps/cp.lua",
|
||||||
|
"halyde/apps/download.lua",
|
||||||
"halyde/apps/echo.lua",
|
"halyde/apps/echo.lua",
|
||||||
"halyde/apps/fetch.lua",
|
"halyde/apps/fetch.lua",
|
||||||
"halyde/apps/help.lua",
|
"halyde/apps/help.lua",
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
local url = ...
|
||||||
|
|
||||||
|
local component = import("component")
|
||||||
|
local fs = import("filesystem")
|
||||||
|
|
||||||
|
if not component.list("internet")() then
|
||||||
|
print("\27[91mThis program requires an internet card to run.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if not url then
|
||||||
|
print("Please enter a URL to download from.")
|
||||||
|
shell.run("help download")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if url:sub(-1, -1) == "/" then
|
||||||
|
url = url:sub(1, -2)
|
||||||
|
end
|
||||||
|
|
||||||
|
local internet = component.internet
|
||||||
|
|
||||||
|
local request, data, tmpdata = nil, "", nil
|
||||||
|
local status, errorMessage = pcall(function()
|
||||||
|
request = internet.request(url)
|
||||||
|
request:finishConnect()
|
||||||
|
end)
|
||||||
|
if not status then
|
||||||
|
print("\27[91mDownload failed: " .. errorMessage)
|
||||||
|
end
|
||||||
|
local responseCode = request:response()
|
||||||
|
if responseCode and responseCode ~= 200 then
|
||||||
|
print("\27[91mDownload failed: " .. tostring(responseCode))
|
||||||
|
end
|
||||||
|
repeat
|
||||||
|
tmpdata = request.read(math.huge)
|
||||||
|
data = data .. (tmpdata or "")
|
||||||
|
until not tmpdata
|
||||||
|
local saveLocation
|
||||||
|
local saveLocationOK = false
|
||||||
|
repeat
|
||||||
|
saveLocation = read(nil, "File save location: ", fs.concat(shell.workingDirectory, url:match("/([^/]+)$")))
|
||||||
|
if fs.isDirectory(saveLocation) then
|
||||||
|
print("\27[91mThe specified location is a directory.")
|
||||||
|
elseif fs.exists(saveLocation) then
|
||||||
|
local answer = read(nil, "\27[91mThere is already a file at the specified directory. Overwrite it? [Y/n]")
|
||||||
|
if answer:lower() ~= "n" then
|
||||||
|
saveLocationOK = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
saveLocationOK = true
|
||||||
|
end
|
||||||
|
until saveLocationOK
|
||||||
|
local handle = fs.open(saveLocation, "w")
|
||||||
|
handle:write(data)
|
||||||
|
handle:close()
|
||||||
|
print("File downloaded successfully.")
|
||||||
@@ -4,6 +4,7 @@ All default Halyde shell commands:
|
|||||||
cd Changes directory.
|
cd Changes directory.
|
||||||
clear Clears the screen.
|
clear Clears the screen.
|
||||||
cp Copies a file.
|
cp Copies a file.
|
||||||
|
download Downloads a file from the internet.
|
||||||
echo Prints a message.
|
echo Prints a message.
|
||||||
edit Opens the text editor.
|
edit Opens the text editor.
|
||||||
fetch Displays system information.
|
fetch Displays system information.
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
Usage: download [URL]
|
||||||
|
Downloads a file from the internet.
|
||||||
|
|
||||||
|
URL Specifies the URL from which to download the file from.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
download https://github.com/ Downloads github.com.
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
local loadfile = ...
|
local loadfile = ...
|
||||||
local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile)
|
local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile)
|
||||||
|
|
||||||
_G._OSVERSION = "Halyde 1.13.0"
|
_G._OSVERSION = "Halyde 1.14.0"
|
||||||
_G._OSLOGO = ""
|
_G._OSLOGO = ""
|
||||||
local handle, tmpdata = filesystem.open("/halyde/config/oslogo.ans", "r"), nil
|
local handle, tmpdata = filesystem.open("/halyde/config/oslogo.ans", "r"), nil
|
||||||
repeat
|
repeat
|
||||||
|
|||||||
+19
-9
@@ -188,16 +188,17 @@ function _G.clear()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- god i hope this silly claude code works first try
|
-- god i hope this silly claude code works first try
|
||||||
|
-- Fluxdrive caught vibe coding???
|
||||||
function _G.read(readHistoryType, prefix, defaultText)
|
function _G.read(readHistoryType, prefix, defaultText)
|
||||||
checkArg(1, readHistoryType, "string", "nil")
|
checkArg(1, readHistoryType, "string", "nil")
|
||||||
checkArg(2, prefix, "string", "nil")
|
checkArg(2, prefix, "string", "nil")
|
||||||
checkArg(3, defaultText, "string", "nil")
|
checkArg(3, defaultText, "string", "nil")
|
||||||
local curtext = defaultText or ""
|
local curtext = defaultText or ""
|
||||||
local prefix = prefix or ""
|
local prefix = prefix or ""
|
||||||
local textCursorPos = unicode.wlen(curtext) + 1 -- Position within the text (1-based)
|
local textCursorPos = unicode.wlen(curtext) + 1 -- Position within the text (1-based)
|
||||||
|
|
||||||
local RHIndex
|
local RHIndex
|
||||||
if readHistoryType then
|
if readHistoryType then
|
||||||
if not termlib.readHistory[readHistoryType] then
|
if not termlib.readHistory[readHistoryType] then
|
||||||
termlib.readHistory[readHistoryType] = {curtext}
|
termlib.readHistory[readHistoryType] = {curtext}
|
||||||
elseif termlib.readHistory[readHistoryType][#termlib.readHistory[readHistoryType]] ~= "" then
|
elseif termlib.readHistory[readHistoryType][#termlib.readHistory[readHistoryType]] ~= "" then
|
||||||
@@ -358,7 +359,16 @@ if readHistoryType then
|
|||||||
end
|
end
|
||||||
|
|
||||||
elseif args[1] == "clipboard" then
|
elseif args[1] == "clipboard" then
|
||||||
-- Handle clipboard paste here if needed
|
-- Handle clipboard paste
|
||||||
|
local text = args[3] or ""
|
||||||
|
local beforeCursor = curtext:sub(1, utf8.offset(curtext, textCursorPos) - 1 or 0)
|
||||||
|
local afterCursor = curtext:sub(utf8.offset(curtext, textCursorPos) or (#curtext + 1))
|
||||||
|
curtext = beforeCursor .. text .. afterCursor
|
||||||
|
textCursorPos = textCursorPos + #text
|
||||||
|
if readHistoryType then
|
||||||
|
termlib.readHistory[readHistoryType][RHIndex] = curtext
|
||||||
|
end
|
||||||
|
redrawLine()
|
||||||
|
|
||||||
else
|
else
|
||||||
-- Cursor blink timing
|
-- Cursor blink timing
|
||||||
|
|||||||
Reference in New Issue
Block a user