Skip to content

Commit

Permalink
scrub: New completion
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Apr 2, 2018
1 parent e00c119 commit 6b5c8d4
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions completions/Makefile.am
Expand Up @@ -343,6 +343,7 @@ bashcomp_DATA = 2to3 \
sbcl \
sbopkg \
screen \
scrub \
sh \
sitecopy \
slackpkg \
Expand Down
36 changes: 36 additions & 0 deletions completions/scrub
@@ -0,0 +1,36 @@
# scrub(1) completion -*- shell-script -*-

_scrub()
{
local cur prev words cword split
_init_completion -s || return

case $prev in
--version|--help|--blocksize|--device-size|--dirent|-!(-*)[vhbsD])
return
;;
--pattern|-!(-*)p)
COMPREPLY=( $( compgen -W '$( "$1" --help 2>&1 |
awk "/^Available/{flag=1;next}/^ /&&flag{print \$1}" )' \
-- "$cur" ) )
return
;;
--freespace|-!(-*)X)
_filedir -d
return
;;
esac

$split && return

if [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return
fi

_filedir
} &&
complete -F _scrub scrub

# ex: filetype=sh
1 change: 1 addition & 0 deletions test/completion/scrub.exp
@@ -0,0 +1 @@
assert_source_completions scrub
24 changes: 24 additions & 0 deletions test/lib/completions/scrub.exp
@@ -0,0 +1,24 @@
proc setup {} {
save_env
}


proc teardown {} {
assert_env_unmodified
}


setup


assert_complete_any "scrub "
sync_after_int

assert_complete_any "scrub -"
sync_after_int

assert_complete_any "scrub -p "
sync_after_int


teardown

0 comments on commit 6b5c8d4

Please sign in to comment.