Skip to content

Commit

Permalink
Merge pull request #114 from Freed-Wu/iss89
Browse files Browse the repository at this point in the history
Fix #89
  • Loading branch information
casperdcl committed Apr 2, 2023
2 parents 1eb80f6 + 40413bb commit 68ac169
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion shtab/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys
from importlib import import_module

from . import SUPPORTED_SHELLS, __version__, complete
from . import SUPPORTED_SHELLS, __version__, add_argument_to, complete

log = logging.getLogger(__name__)

Expand All @@ -26,6 +26,7 @@ def get_main_parser():
)
parser.add_argument("--verbose", dest="loglevel", action="store_const", default=logging.INFO,
const=logging.DEBUG, help="Log debug information")
add_argument_to(parser, "--print-own-completion", help="print shtab's own completion")
return parser


Expand Down
18 changes: 18 additions & 0 deletions tests/test_shtab.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@ def test_main(shell, caplog):
assert not caplog.record_tuples


@fix_shell
def test_main_self_completion(shell, caplog, capsys):
with caplog.at_level(logging.INFO):
try:
main(["--print-own-completion", shell])
except SystemExit:
pass

captured = capsys.readouterr()
assert not captured.err
expected = {
"bash": "complete -o filenames -F _shtab_shtab shtab", "zsh": "_shtab_shtab_commands()",
"tcsh": "complete shtab"}
assert expected[shell] in captured.out

assert not caplog.record_tuples


@fix_shell
def test_prog_override(shell, caplog, capsys):
with caplog.at_level(logging.INFO):
Expand Down

0 comments on commit 68ac169

Please sign in to comment.