-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlsdev.lua
More file actions
32 lines (29 loc) · 1.14 KB
/
lsdev.lua
File metadata and controls
32 lines (29 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
local hardware = require "system.hardware"
local util = require "system.util"
local args = assert(util.argparse({v = false}, ...))
local function list(node, level)
for _, v in ipairs(hardware.children(node)) do
local info = hardware.info(node .. "/" .. v)
if args.v then
print(("%sDevice %s (%s): %s"):format((" "):rep(level), v, info.uuid, info.displayName or ""))
io.write((" "):rep(level) .. "Types: ")
local start = true
for k, w in pairs(info.types) do io.write((start and "" or ", ") .. k .. " (" .. w .. ")") start = false end
print()
else
print(("%sDevice %s: %s"):format((" "):rep(level), v, info.displayName or ""))
end
list(node .. "/" .. v, level + 2)
end
end
local info = hardware.info("/")
if args.v then
print(("Device / (%s): %s"):format(info.uuid, info.displayName or ""))
io.write("Types: ")
local start = true
for k, w in pairs(info.types) do io.write((start and "" or ", ") .. k .. " (" .. w .. ")") start = false end
print()
else
print(("Device /: %s"):format(info.displayName or ""))
end
list("/", 2)