OctOS: Allow specifying command to get help for with help command

master
octacian 2017-03-28 16:35:25 -07:00
parent c4bd091ae8
commit 662c265cab
1 changed files with 22 additions and 10 deletions

View File

@ -2,16 +2,28 @@
local params = ...
local bin = get_userdata("bin")
local param = params[1]
if params[1] == "all" then
for name, info in pairs(bin) do
local params = ""
if info.params then
params = " "..info.params
end
print(name..params..": "..info.description)
-- [local function] Print help
local function print_h(name, info)
local params = ""
if info.params then
params = " "..info.params
end
print(name..params..": "..info.description)
end
if param == "all" then
for name, info in pairs(bin) do
print_h(name, info)
end
elseif not param or param == "" then
print("Specify a command to get help for or use help all to view help for all commands.")
else
if bin[param] then
print_h(param, bin[param])
else
print(param..": command not found")
end
else
print("Specify a command to get help for or use help all to view help for all commands.")
end