Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help Command - Inline Types #325

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions Cmdr/BuiltInCommands/help.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Tips

return {
Name = "help",
Aliases = { "cmds", "commands" },
Description = "Displays a list of all commands, or inspects one command.",
Group = "Help",
Args = {
Expand All @@ -36,20 +35,17 @@ return {
if command.Aliases and #command.Aliases > 0 then
context:Reply(`Aliases: {table.concat(command.Aliases, ", ")}`, Color3.fromRGB(230, 230, 230))
end
if command.Description then
context:Reply(`Description: {command.Description}`, Color3.fromRGB(230, 230, 230))
end
if command.Group then
context:Reply(`Group: {command.Group}`, Color3.fromRGB(230, 230, 230))
end
if command.Args then
for i, arg in ipairs(command.Args) do
context:Reply(
`#{i} {if type(arg) == "table"
then `{arg.Name}{if arg.Optional == true then "?" else ""}: {arg.Type} - {arg.Description}`
else "Unknown (inline argument)"}`
)
context:Reply(command.Description, Color3.fromRGB(230, 230, 230))
for i, arg in ipairs(command.Args) do
if type(arg) == "function" then
arg = arg(arg)
end

context:Reply(
`{arg.Name}{if arg.Optional then "?" else ""}: {if type(arg.Type) == "string"
then arg.Type
else arg.Type.DisplayName} - {arg.Description}`
)
end
else
context:Reply(ARGUMENT_SHORTHANDS)
Expand All @@ -61,10 +57,10 @@ return {
end)
local lastGroup
for _, command in ipairs(commands) do
local group = command.Group or "No Group"
if lastGroup ~= group then
context:Reply(`\n{group}\n{string.rep("-", #group)}`)
lastGroup = group
command.Group = command.Group or "No Group"
if lastGroup ~= command.Group then
context:Reply(`\n{command.Group}\n{string.rep("-", #command.Group)}`)
lastGroup = command.Group
end
context:Reply(if command.Description then `{command.Name} - {command.Description}` else command.Name)
end
Expand Down
Loading