Browse Source

freshnaut: Send all binary garbage to stderr

master
mid-kid 8 years ago
parent
commit
5a1378e8d6
  1. 27
      astronaut/freshnaut

27
astronaut/freshnaut

@ -90,14 +90,17 @@ function get_available_versions(satellite)
return return
end end
io.write("\x1B[1K\r" .. satellite .. ": Downloading update file...") io.stderr:write("\x1B[1K\r")
io.stderr:write(satellite .. ": Downloading update file...")
local update_file = download(update_url) local update_file = download(update_url)
if not update_file then if not update_file then
print("\x1B[1K\rWARNING: " .. satellite .. ": Failed to download " .. update_url) io.stderr:write("\x1B[1K\r")
print("WARNING: " .. satellite .. ": Failed to download " .. update_url)
return return
end end
io.write("\x1B[1K\r" .. satellite .. ": Getting available versions...") io.stderr:write("\x1B[1K\r")
io.stderr:write(satellite .. ": Getting available versions...")
-- Try getting variable update_names, get downloads otherwise. -- Try getting variable update_names, get downloads otherwise.
local update_names = astrohelp(satellite, "variable update_names") local update_names = astrohelp(satellite, "variable update_names")
if not update_names then if not update_names then
@ -130,11 +133,13 @@ function get_available_versions(satellite)
end end
end end
io.stderr:write("\x1B[1K\r")
if count < 1 then if count < 1 then
print("\x1B[1K\rWARNING: " .. satellite .. ": Couldn't retrieve any versions") print("WARNING: " .. satellite .. ": Couldn't retrieve any versions")
return return
elseif not versions[version] then elseif not versions[version] then
print("\x1B[1K\rWARNING: " .. satellite .. ": Current version isn't available") print("WARNING: " .. satellite .. ": Current version isn't available")
end end
return versions, update_url return versions, update_url
@ -161,7 +166,7 @@ function check_new_versions(satellite, version_file_path)
old_versions[version] = true old_versions[version] = true
end end
else else
print("\x1B[1K\r" .. satellite .. ": First check") print(satellite .. ": First check")
version_file = io.open(version_file_path, "w") version_file = io.open(version_file_path, "w")
assert(version_file, "Failed to create " .. version_file_path) assert(version_file, "Failed to create " .. version_file_path)
end end
@ -180,11 +185,11 @@ function check_new_versions(satellite, version_file_path)
end end
if #new_versions > 0 then if #new_versions > 0 then
print("\x1B[1K\r" .. satellite .. ": From '" .. update_url .. "'") print(satellite .. ": From '" .. update_url .. "'")
for _, version in ipairs(new_versions) do for _, version in ipairs(new_versions) do
version_file:write(version .. "\n") version_file:write(version .. "\n")
print("\x1B[1K\r" .. satellite .. ": " .. version) print(satellite .. ": " .. version)
end end
end end
@ -214,11 +219,11 @@ elseif arg[1] == "dir" then
if cols then if cols then
cols = tonumber(cols) cols = tonumber(cols)
local countstr = tostring(count) .. "/" .. tostring(total) local countstr = tostring(count) .. "/" .. tostring(total)
io.write("\r") io.stderr:write("\r")
for i = 1, cols - countstr:len() - 1 do for i = 1, cols - countstr:len() - 1 do
io.write(" ") io.stderr:write(" ")
end end
io.write(countstr .. "\r") io.stderr:write(countstr .. "\r")
end end
local version_file = version_dir .. "/" .. satellite local version_file = version_dir .. "/" .. satellite

Loading…
Cancel
Save