Skip to content

Commit

Permalink
Fixed OpenOS diagnostics in the vscode Lua plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
Possseidon authored and asiekierka committed Jun 3, 2023
1 parent 66bd036 commit c053c0f
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ end

local function readRom()
local eeprom = component.eeprom
fileName = shell.resolve(args[1])
local fileName = shell.resolve(args[1])
if not options.q then
if fs.exists(fileName) then
io.write("Are you sure you want to overwrite " .. fileName .. "?\n")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local shell = require("shell")
local fs = require("filesystem")

local args, options = shell.parse(...)
local error_code = 0
Expand All @@ -26,11 +25,6 @@ quiet = quiet[1] or quiet[2] or quiet[3]
local verbose = {pop('v'), pop('verbose')}
verbose = verbose[1] or verbose[2]
local help = pop('help')
local invalid_key = next(options)

if bytes and lines then
invalid_key = 'bytes and lines both specified'
end

if help or next(options) then
local invalid_key = next(options)
Expand Down Expand Up @@ -111,7 +105,7 @@ end

for i=1,#args do
local arg = args[i]
local file
local file, reason
if arg == '-' then
arg = 'standard input'
file = io.stdin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if options.a then
end
end
else
proxy, reason = devfs.getDevice(args[1])
proxy, reason = devfs.getDevice(filter)
end

if not proxy then
Expand All @@ -45,5 +45,5 @@ if #args < 2 then
return 1
end
else
devfs.setDeviceLabel(proxy, args[2])
devfs.setDeviceLabel(proxy, label)
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
local component = require("component")
local fs = require("filesystem")
local shell = require("shell")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ local function get(pasteId, filename)
end

-- This makes a string safe for being used in a URL.
function encode(code)
local function encode(code)
if code then
code = string.gsub(code, "([^%w ])", function (c)
return string.format("%%%02X", string.byte(c))
end)
code = string.gsub(code, " ", "+")
end
return code
return code
end

-- This stores the program in a temporary file, which it will
-- delete after the program was executed.
function run(pasteId, ...)
local function run(pasteId, ...)
local tmpFile = os.tmpname()
get(pasteId, tmpFile)
io.write("Running...\n")
Expand All @@ -68,7 +68,7 @@ function run(pasteId, ...)
end

-- Uploads the specified file as a new paste to pastebin.com.
function put(path)
local function put(path)
local config = {}
local configFile = loadfile("/etc/pastebin.conf", "t", config)
if configFile then
Expand All @@ -90,7 +90,7 @@ function put(path)

io.write("Uploading to pastebin.com... ")
local result, response = pcall(internet.request,
"https://pastebin.com/api/api_post.php",
"https://pastebin.com/api/api_post.php",
"api_option=paste&" ..
"api_dev_key=" .. config.key .. "&" ..
"api_paste_format=lua&" ..
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
local process = require("process")
local unicode = require("unicode")
local event = require("event")
local thread = require("thread")
local event_mt = getmetatable(event.handlers)

-- WARNING this code does not use official kernel API and is likely to change
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ local function confirm()
return r == 'y' or r == 'yes'
end

local remove

local function remove_all(parent)
if parent == nil or not _dir(parent) or _empty(parent) then
return true
Expand All @@ -93,7 +95,7 @@ local function remove_all(parent)
return all_ok
end

local function remove(meta)
remove = function(meta)
if not remove_all(meta) then
return false
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ local function remove(path, ...)
return ec_bump()
else
local list, reason = fs.list(rpath)

if not list then
io.stderr:write(tostring(reason)..'\n')
return ec_bump()
Expand Down Expand Up @@ -88,7 +88,7 @@ for _,path in ipairs(args) do

local segments = {}
if options.p and path:len() > 1 and path:find('/') then
chain = text.split(path, {'/'}, true)
local chain = text.split(path, {'/'}, true)
local prefix = ''
for _,e in ipairs(chain) do
table.insert(segments, 1, prefix .. e)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local shell = require("shell")
local tty = require("tty")
local args, options = shell.parse(...)

if options.help then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ end

function api.proxy.list(path)
local result = {}
for name in pairs(dynamic_list(path, false, false)) do
for name in pairs(dynamic_list(path, false)) do
table.insert(result, name)
end
return result
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
local buffer = require("buffer")
local component = require("component")
local event = require("event")

local internet = {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ keyboard.keys = {
tab = 0x0F,
up = 0xC8,
["end"] = 0xCF,
enter = 0x1C,
tab = 0x0F,
numpadenter = 0x9C,
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
local fs = require("filesystem")
local shell = require("shell")
local text = require("text")
local lib = {}

local function perr(ops, format, ...)
Expand Down Expand Up @@ -141,7 +140,7 @@ function lib.recurse(fromPath, toPath, options, origin, top)
if mv and is_mount then
return false, string.format("cannot move '%s', it is a mount point", fromPath)
end

if fromIsLink and options.P and not (toExists and same_path and not toIsLink) then
if toExists and options.n then
return true
Expand Down

0 comments on commit c053c0f

Please sign in to comment.