From 4289460691719255ca5d34c04d2a7cacc6ccd1ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Tue, 7 Jul 2015 17:50:36 +0300 Subject: [PATCH] pdftotext: New completion --- completions/Makefile.am | 1 + completions/pdftotext | 36 ++++++++++++++++++++++++++++++ test/completion/pdftotext.exp | 1 + test/lib/completions/pdftotext.exp | 18 +++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 completions/pdftotext create mode 100644 test/completion/pdftotext.exp create mode 100644 test/lib/completions/pdftotext.exp diff --git a/completions/Makefile.am b/completions/Makefile.am index e3060c53..d535126f 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -256,6 +256,7 @@ bashcomp_DATA = 2to3 \ pack200 \ passwd \ patch \ + pdftotext \ perl \ pgrep \ pidof \ diff --git a/completions/pdftotext b/completions/pdftotext new file mode 100644 index 00000000..8c10d828 --- /dev/null +++ b/completions/pdftotext @@ -0,0 +1,36 @@ +# bash completion for pdftotext(1) -*- shell-script -*- + +_pdftotext() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -h|-help|--help|-'?'|-f|-l|-r|-x|-y|-W|-H|-fixed|-opw|-upw) + return + ;; + -enc) + COMPREPLY=( $( compgen -W '$( "$1" -listenc 2>/dev/null | + sed -e 1d )' -- "$cur" ) ) + return + ;; + -eol) + COMPREPLY=( $( compgen -W "unix dos mac" -- "$cur" ) ) + return + ;; + esac + + if [[ $cur == -* && ${prev,,} != *.pdf ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + return + fi + + case ${prev,,} in + -|*.txt) ;; + *.pdf) COMPREPLY=( $( compgen -W '-' -- "$cur" ) ) ; _filedir txt ;; + *) _filedir pdf ;; + esac +} && +complete -F _pdftotext pdftotext + +# ex: ts=4 sw=4 et filetype=sh diff --git a/test/completion/pdftotext.exp b/test/completion/pdftotext.exp new file mode 100644 index 00000000..d84cee5d --- /dev/null +++ b/test/completion/pdftotext.exp @@ -0,0 +1 @@ +assert_source_completions pdftotext diff --git a/test/lib/completions/pdftotext.exp b/test/lib/completions/pdftotext.exp new file mode 100644 index 00000000..4c5cfca5 --- /dev/null +++ b/test/lib/completions/pdftotext.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pdftotext " +sync_after_int + + +teardown