1
0
mirror of https://github.com/Adorable-Catgirl/LuaComp.git synced 2024-11-23 02:18:06 +11:00

Oh yeah, competion time.

This commit is contained in:
Jane Roxanne 2019-12-15 12:56:50 -05:00
parent 82d10aa87a
commit 6dd2dca097
2 changed files with 45 additions and 2 deletions

24
completion/zsh/_luacomp Normal file
View File

@ -0,0 +1,24 @@
#compdef luacomp
_luacomp() {
local -a options=(
{-h,--help}"[Show this help message and exit]"
{-O,--output}"[Output file]: :_files"
{-m,--minifier}"[Sets the postprocessor (default\: none)]: :( ${(f)'luacomp --post-processors'} )"
{-x,--executable}"[Makes the script an executable (default\: current lua version)]: :_path_commands"
"--generator-code[Outputs only the code from the generator]"
"--verbose[Verbose output]"
"--post-processors[Lists postprocessors]"
"--directives[Lists directives]"
{-v,--version}"[Prints the version and exits]"
"--completion[Output a shell completion script for the specified shell]: :(bash zsh fish)"
)
_arguments -s -S \
$options \
": :_files" \
&& return 0
return 1
}
_luacomp

View File

@ -22,12 +22,31 @@ parser:option("-m --minifier", "Sets the postprocessor", "none")
parser:option("-x --executable", "Makes the script an executable (default: current lua version)"):args "?"
parser:flag("--generator-code", "Outputs only the code from the generator.")
parser:flag("--verbose", "Verbose output. (Debugging)"):action(function() VERBOSE=true end)
parser:flag("--post-processors", "Lists postprocessors"):action(function() preload_providers() for k, v in pairs(providers) do print(k) end os.exit(0) end)
parser:flag("--directives", "Lists directives"):action(function() preload_directives() for k, v in pairs(directives) do print(k) end os.exit(0) end)
parser:flag("--post-processors", "Lists postprocessors"):action(function()
preload_providers()
local provs = {}
for k, v in pairs(providers) do
provs[#provs+1] = k
end
table.sort(provs)
print(table.concat(provs, "\n"))
os.exit(0)
end)
parser:flag("--directives", "Lists directives"):action(function()
preload_directives()
local dirs = {}
for k, v in pairs(directives) do
dirs[#dirs+1] = k
end
table.sort(dirs)
print(table.concat(dirs, "\n"))
os.exit(0)
end)
parser:flag("-v --version", "Prints the version and exits"):action(function()
print(LUACOMP_VERSION)
os.exit(0)
end)
parser:add_complete()
local args = parser:parse()
local file = args.input
_sv("LUACOMP_MINIFIER", args.minifier)