Skip to content

Commit 56c3ea1

Browse files
committed
zopflipng: New completion
1 parent 20f9013 commit 56c3ea1

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

completions/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,8 @@ bashcomp_DATA = 2to3 \
410410
ypmatch \
411411
_yum \
412412
yum-arch \
413-
zopfli
413+
zopfli \
414+
zopflipng
414415

415416
EXTRA_DIST = $(bashcomp_DATA)
416417

completions/zopflipng

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# bash completion for zopflipng -*- shell-script -*-
2+
3+
_zopflipng()
4+
{
5+
local cur prev words cword split
6+
_init_completion -s || return
7+
8+
case $prev in
9+
-h|--help)
10+
return
11+
;;
12+
--splitting)
13+
COMPREPLY=( $( compgen -W '{0..3}' -- "$cur" ) )
14+
return
15+
;;
16+
esac
17+
18+
$split && return
19+
20+
if [[ "$cur" == -* ]]; then
21+
COMPREPLY=( $( _parse_help "$1" -h ) )
22+
COMPREPLY=( $( compgen -W '${COMPREPLY[@]%:}' -- "$cur" ) )
23+
[[ $COMPREPLY == *= ]] && compopt -o nospace
24+
return
25+
fi
26+
27+
if [[ ${words[@]} != *\ --prefix=* ]]; then
28+
# 2 png args only if --prefix not given
29+
local args
30+
_count_args
31+
[[ $args -lt 3 ]] && _filedir png
32+
else
33+
# otherwise arbitrary number of png args
34+
_filedir png
35+
fi
36+
} &&
37+
complete -F _zopflipng zopflipng
38+
39+
# ex: ts=4 sw=4 et filetype=sh

test/completion/zopflipng.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
assert_source_completions zopflipng

test/lib/completions/zopflipng.exp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
proc setup {} {
2+
save_env
3+
}
4+
5+
6+
proc teardown {} {
7+
assert_env_unmodified
8+
}
9+
10+
11+
setup
12+
13+
14+
assert_complete_any "zopflipng "
15+
sync_after_int
16+
17+
18+
teardown

0 commit comments

Comments
 (0)