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 #326

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions Cmdr/BuiltInCommands/help.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ return {
end
if command.Args then
for i, arg in ipairs(command.Args) do
if type(arg) == "function" then
arg = arg(arg)
end

context:Reply(
`#{i} {if type(arg) == "table"
then `{arg.Name}{if arg.Optional == true then "?" else ""}: {arg.Type} - {arg.Description}`
else "Unknown (inline argument)"}`
`{arg.Name}{if arg.Optional then "?" else ""}: {if type(arg.Type) == "string" then arg.Type else arg.Type.DisplayName} - {arg.Description}`
)
end
end
Expand Down
1 change: 1 addition & 0 deletions Cmdr/Shared/Util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ end
function Util.MakeEnumType(name: string, values: any)
local findValue = Util.MakeFuzzyFinder(values)
return {
DisplayName = name,
Validate = function(text)
return findValue(text, true) ~= nil, ("Value %q is not a valid %s."):format(text, name)
end,
Expand Down
Loading