Replace Utility.capitalize with Utility.pascalCase to capitalize every word in a string

main
AreiaAard 4 years ago
parent 00f6680196
commit 1b4192257a

@ -215,7 +215,7 @@ function Settings.ignore_flag_display()
Utility.plugin_msg("Ignored flags:") Utility.plugin_msg("Ignored flags:")
for _, flag in ipairs{"aimed", "evil", "good", "sanctuary", "wounded"} do for _, flag in ipairs{"aimed", "evil", "good", "sanctuary", "wounded"} do
Utility.print(string.format(" @Y%-11.11s (%-5.5s@w)", Utility.print(string.format(" @Y%-11.11s (%-5.5s@w)",
Utility.capitalize(flag), Settings.config.ignore.flags[flag] and "@GYes" or "@RNo" Utility.pascalCase(flag), Settings.config.ignore.flags[flag] and "@GYes" or "@RNo"
)) ))
end end
end end
@ -622,8 +622,12 @@ function Utility.display_help()
Utility.print("TODO") Utility.print("TODO")
end end
function Utility.capitalize(str) function Utility.pascalCase(str)
return string.format("%s%s", str:sub(1, 1):upper(), str:sub(2)) return str:gsub("(%a)([%w_']*)",
function(first,remainder)
return string.format("%s%s", first:upper(), remainder:lower())
end
)
end end

Loading…
Cancel
Save