Skip to content

Commit 2059ac8

Browse files
committed
feat(tree): new completion
1 parent 4002458 commit 2059ac8

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed

completions/Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ bashcomp_DATA = 2to3 \
419419
tipc \
420420
tox \
421421
tracepath \
422+
tree \
422423
tshark \
423424
tsig-keygen \
424425
tune2fs \

completions/tree

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# tree(1) completion -*- shell-script -*-
2+
3+
_comp_cmd_tree()
4+
{
5+
local cur prev words cword
6+
_init_completion || return
7+
8+
case $prev in
9+
-!(-*)[LPIHT] | --filelimit | --timefmt | --help | --version)
10+
return
11+
;;
12+
--charset)
13+
_xfunc iconv _iconv_charsets
14+
return
15+
;;
16+
-!(-*)o)
17+
_filedir
18+
return
19+
;;
20+
--sort)
21+
COMPREPLY=($(compgen -W "name version size mtime ctime" -- "$cur"))
22+
return
23+
;;
24+
esac
25+
26+
if [[ $cur == -* ]]; then
27+
COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
28+
return
29+
fi
30+
31+
if [[ ${words[*]} == *\ --fromfile\ * ]]; then
32+
_filedir
33+
else
34+
_filedir -d
35+
fi
36+
} &&
37+
complete -F _comp_cmd_tree tree
38+
39+
# ex: filetype=sh

test/t/Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ EXTRA_DIST = \
610610
test_tox.py \
611611
test_tr.py \
612612
test_tracepath.py \
613+
test_tree.py \
613614
test_tshark.py \
614615
test_tsig_keygen.py \
615616
test_tune2fs.py \

test/t/test_tree.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import pytest
2+
3+
4+
class TestTree:
5+
@pytest.mark.complete("tree ", cwd="shared/default")
6+
def test_basic(self, completion):
7+
assert completion == ["bar bar.d/", "foo.d/"]
8+
9+
@pytest.mark.complete("tree --fromfile ", cwd="shared/default")
10+
def test_fromfile(self, completion):
11+
assert completion == ["bar", "bar bar.d/", "foo", "foo.d/"]
12+
13+
@pytest.mark.complete("tree -", require_cmd=True)
14+
def test_options(self, completion):
15+
assert completion

test/test-cmd-list.txt

+1
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ touch
374374
tox
375375
tr
376376
tracepath
377+
tree
377378
tshark
378379
tsig-keygen
379380
tune2fs

0 commit comments

Comments
 (0)