OC-Tsuki/coreutils/uname.lua
Jane Roxanne e44d6177a0 kio++
2020-06-02 01:14:26 -05:00

58 lines
1.1 KiB
Lua

local sharg = require("sh_arg")
local args = sharg({
name = "uname",
desc = [[Print certain system information. With no OPTION, same as -s]],
options = {
{"kernel-name", "s", "print the kernel name"},
{"nodename", "n", "print the network node hostname"},
{"kernel-release", "r", "print the kernel release"},
{"kernel-version", "v", "print the kernel release"},
{"machine", "m", "print the machine hardware name"},
{"operating-system", "o", "print the operating system"},
{"version", false, "output version information and exit"}
},
}, ...)
if (args.version) then
version_info()
return 0
end
if (args.a or args.all) then
args.s = true
args.r = true
args.v = true
args.n = true
args.m = true
args.o = true
end
if table.select("#", ...) == 0 then
args.s = true
end
if (args.s) then
io.stdout:write(_KINFO.name.." ")
end
if (args.n) then
io.stdout:write(os.getenv("HOSTNAME").." ")
end
if (args.r) then
io.stdout:write(_KINFO.release.." ")
end
if (args.v) then
io.stdout:write(_KINFO.version.." ")
end
if (args.m) then
io.stdout:write(_KINFO.machine.." ")
end
if (args.o) then
io.stdout:write("SKS/Tsuki ")
end
io.stdout:write("\n")