Remove support for disabling completion option

It is disabled by default
This commit is contained in:
Paul Ouellette
2019-05-31 21:19:48 -04:00
parent d5e15583b8
commit 46622e83de

View File

@@ -204,9 +204,6 @@ local add_help = {"add_help", function(self, value)
if self._help_option_idx then if self._help_option_idx then
table.remove(self._options, self._help_option_idx) table.remove(self._options, self._help_option_idx)
if self._complete_option_idx and self._complete_option_idx > self._help_option_idx then
self._complete_option_idx = self._complete_option_idx - 1
end
self._help_option_idx = nil self._help_option_idx = nil
end end
@@ -231,35 +228,23 @@ local add_help = {"add_help", function(self, value)
end} end}
local add_complete = {"add_complete", function(self, value) local add_complete = {"add_complete", function(self, value)
typecheck("add_complete", {"boolean", "string", "table"}, value) typecheck("add_complete", {"nil", "string", "table"}, value)
if self._complete_option_idx then local complete = self:option()
table.remove(self._options, self._complete_option_idx) :description "Output a shell completion script for the specified shell."
if self._help_option_idx and self._help_option_idx > self._complete_option_idx then :args(1)
self._help_option_idx = self._help_option_idx - 1 :choices {"bash", "zsh", "fish"}
end :action(function(_, _, shell)
self._complete_option_idx = nil print(self["get_" .. shell .. "_complete"](self))
end os.exit(0)
end)
if value then if value then
local complete = self:option() complete = complete(value)
:description "Output a shell completion script for the specified shell." end
:args(1)
:choices {"bash", "zsh", "fish"}
:action(function(_, _, shell)
print(self["get_" .. shell .. "_complete"](self))
os.exit(0)
end)
if value ~= true then if not complete._name then
complete = complete(value) complete "--completion"
end
if not complete._name then
complete "--completion"
end
self._complete_option_idx = #self._options
end end
end} end}