Skip to content
Open
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
6 changes: 1 addition & 5 deletions shtab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,6 @@ def recurse(parser, prefix):
options_strings_str = "' '".join(get_option_strings(parser))
option_strings.append(f"{prefix}_option_strings=('{options_strings_str}')")
for optional in parser._get_optional_actions():
if optional == SUPPRESS:
continue

for option_string in optional.option_strings:
if hasattr(optional, "complete"):
# shtab `.complete = ...` functions
Expand Down Expand Up @@ -440,8 +437,7 @@ def complete_bash(parser, root_prefix=None, preamble="", choice_functions=None):
if [[ $pos_only = 0 && "${completing_word}" == -* ]]; then
# optional argument started: use option strings
COMPREPLY=( $(compgen -W "${current_option_strings[*]}" -- "${completing_word}") )
elif [[ "${previous_word}" == ">" || "${previous_word}" == ">>" ||
"${previous_word}" =~ ^[12]">" || "${previous_word}" =~ ^[12]">>" ]]; then
elif [[ "${previous_word}" =~ ^[0-9\\&]*[\\<\\>]\\>?$ ]]; then
# handle redirection operators
COMPREPLY=( $(compgen -f -- "${completing_word}") )
else
Expand Down
3 changes: 1 addition & 2 deletions shtab/__main__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import logging
import sys

from .main import main

if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
sys.exit(main(sys.argv[1:]) or 0)
main()
2 changes: 1 addition & 1 deletion tests/test_shtab.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def test_add_argument_to_positional(shell, caplog, capsys):
completion_manual = shtab.complete(parser, shell=shell)
with pytest.raises(SystemExit) as exc:
sub._actions[-1](sub, Namespace(), shell)
assert exc.type == SystemExit
assert exc.type is SystemExit
assert exc.value.code == 0
completion, err = capsys.readouterr()
print(completion)
Expand Down