mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-27 18:42:20 +00:00
Remove support for disabling completion option
It is disabled by default
This commit is contained in:
@@ -204,9 +204,6 @@ local add_help = {"add_help", function(self, value)
|
||||
|
||||
if self._help_option_idx then
|
||||
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
|
||||
end
|
||||
|
||||
@@ -231,35 +228,23 @@ local add_help = {"add_help", function(self, value)
|
||||
end}
|
||||
|
||||
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
|
||||
table.remove(self._options, self._complete_option_idx)
|
||||
if self._help_option_idx and self._help_option_idx > self._complete_option_idx then
|
||||
self._help_option_idx = self._help_option_idx - 1
|
||||
end
|
||||
self._complete_option_idx = nil
|
||||
end
|
||||
local complete = self:option()
|
||||
:description "Output a shell completion script for the specified shell."
|
||||
:args(1)
|
||||
:choices {"bash", "zsh", "fish"}
|
||||
:action(function(_, _, shell)
|
||||
print(self["get_" .. shell .. "_complete"](self))
|
||||
os.exit(0)
|
||||
end)
|
||||
|
||||
if value then
|
||||
local complete = self:option()
|
||||
:description "Output a shell completion script for the specified shell."
|
||||
:args(1)
|
||||
:choices {"bash", "zsh", "fish"}
|
||||
:action(function(_, _, shell)
|
||||
print(self["get_" .. shell .. "_complete"](self))
|
||||
os.exit(0)
|
||||
end)
|
||||
complete = complete(value)
|
||||
end
|
||||
|
||||
if value ~= true then
|
||||
complete = complete(value)
|
||||
end
|
||||
|
||||
if not complete._name then
|
||||
complete "--completion"
|
||||
end
|
||||
|
||||
self._complete_option_idx = #self._options
|
||||
if not complete._name then
|
||||
complete "--completion"
|
||||
end
|
||||
end}
|
||||
|
||||
|
Reference in New Issue
Block a user