OctOS: Add `params` field to applications

Shows parameters for each command in help.
master
octacian 2017-03-28 16:31:00 -07:00
parent 3c2fa52b4f
commit c4bd091ae8
6 changed files with 12 additions and 2 deletions

View File

@ -1,11 +1,12 @@
# Applications with OctOS
OctOS has a simple framework to allow the player to easily create their own programs for their computers. All you have to do, is place a file in the `bin` directory to tell OctOS about your application, while the code is typically placed in `exec`.
Files in `bin` do not have to follow any naming convention and typically do not even have an extension. They are formatted as shown below, `name` and `exec` being the only required fields. If `name` is not defined, the file name will be used.
Files in `bin` do not have to follow any naming convention and typically do not even have an extension. They are formatted as shown below, `name` and `exec` being the only required fields. If `name` is not defined, the file name will be used. Parameters are shown just after the command name in help, and just before the description.
```
name = <name>
description = <description>
params = <parameters>
exec = <path to code (e.g. os/exec/help.lua)>
```

View File

@ -1,3 +1,4 @@
name = echo
description = Print text to the command line
params = [text]
exec = os/exec/echo.lua

View File

@ -1,3 +1,4 @@
name = help
description = Show help information
params = [command / "all"]
exec = os/exec/help.lua

View File

@ -1,3 +1,4 @@
name = lua
description = Execute Lua code
params = [code]
exec = os/exec/lua.lua

View File

@ -5,7 +5,12 @@ local bin = get_userdata("bin")
if params[1] == "all" then
for name, info in pairs(bin) do
print(name..": "..info.description)
local params = ""
if info.params then
params = " "..info.params
end
print(name..params..": "..info.description)
end
else
print("Specify a command to get help for or use help all to view help for all commands.")

View File

@ -16,6 +16,7 @@ for _,f in ipairs(bin_contents.files) do
bin[name] = {
description = cmd_info.description or "",
params = cmd_info.params or "",
exec = cmd_info.exec or "os/exec/nil"
}
end