Skip to content

Commit 9b535a1

Browse files
committed
feat(truncate): new completion
1 parent e7497f6 commit 9b535a1

File tree

5 files changed

+44
-0
lines changed

5 files changed

+44
-0
lines changed

completions/Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ bashcomp_DATA = 2to3 \
420420
tox \
421421
tracepath \
422422
tree \
423+
truncate \
423424
tshark \
424425
tsig-keygen \
425426
tune2fs \

completions/truncate

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# truncate(1) completion -*- shell-script -*-
2+
3+
_comp_cmd_truncate()
4+
{
5+
local cur prev words cword split
6+
_init_completion -s || return
7+
8+
case $prev in
9+
-!(-*)s | --size | --help | --version)
10+
return
11+
;;
12+
-!(-*)r | --reference)
13+
_filedir
14+
return
15+
;;
16+
esac
17+
18+
$split && return
19+
20+
if [[ $cur == -* ]]; then
21+
COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
22+
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
23+
return
24+
fi
25+
26+
_filedir
27+
} &&
28+
complete -F _comp_cmd_truncate truncate
29+
30+
# ex: filetype=sh

test/t/Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ EXTRA_DIST = \
612612
test_tr.py \
613613
test_tracepath.py \
614614
test_tree.py \
615+
test_truncate.py \
615616
test_tshark.py \
616617
test_tsig_keygen.py \
617618
test_tune2fs.py \

test/t/test_truncate.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest
2+
3+
4+
class TestTruncate:
5+
@pytest.mark.complete("truncate ")
6+
def test_basic(self, completion):
7+
assert completion
8+
9+
@pytest.mark.complete("truncate -", require_cmd=True)
10+
def test_options(self, completion):
11+
assert completion

test/test-cmd-list.txt

+1
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ tox
379379
tr
380380
tracepath
381381
tree
382+
truncate
382383
tshark
383384
tsig-keygen
384385
tune2fs

0 commit comments

Comments
 (0)