Skip to content

Commit 68ac169

Browse files
authored
Merge pull request #114 from Freed-Wu/iss89
Fix #89
2 parents 1eb80f6 + 40413bb commit 68ac169

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

shtab/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sys
55
from importlib import import_module
66

7-
from . import SUPPORTED_SHELLS, __version__, complete
7+
from . import SUPPORTED_SHELLS, __version__, add_argument_to, complete
88

99
log = logging.getLogger(__name__)
1010

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

3132

tests/test_shtab.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,24 @@ def test_main(shell, caplog):
6464
assert not caplog.record_tuples
6565

6666

67+
@fix_shell
68+
def test_main_self_completion(shell, caplog, capsys):
69+
with caplog.at_level(logging.INFO):
70+
try:
71+
main(["--print-own-completion", shell])
72+
except SystemExit:
73+
pass
74+
75+
captured = capsys.readouterr()
76+
assert not captured.err
77+
expected = {
78+
"bash": "complete -o filenames -F _shtab_shtab shtab", "zsh": "_shtab_shtab_commands()",
79+
"tcsh": "complete shtab"}
80+
assert expected[shell] in captured.out
81+
82+
assert not caplog.record_tuples
83+
84+
6785
@fix_shell
6886
def test_prog_override(shell, caplog, capsys):
6987
with caplog.at_level(logging.INFO):

0 commit comments

Comments
 (0)