summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Command/.distfiles1
-rw-r--r--Completion/Unix/Command/_bogofilter57
2 files changed, 58 insertions, 0 deletions
diff --git a/Completion/Unix/Command/.distfiles b/Completion/Unix/Command/.distfiles
index da26b0a63..64e6448a1 100644
--- a/Completion/Unix/Command/.distfiles
+++ b/Completion/Unix/Command/.distfiles
@@ -25,4 +25,5 @@ _mt           _mtr          _nice         _nmap
 _perforce     _printenv     _python       _raggle       _rar	      _renice
 _sablotron    _screen       _sed          _subversion   _tla          _php
 _uniq         _vorbis       _vux          _wiggle       _xmlsoft
+_bogofilter
 '
diff --git a/Completion/Unix/Command/_bogofilter b/Completion/Unix/Command/_bogofilter
new file mode 100644
index 000000000..dcf8fdb71
--- /dev/null
+++ b/Completion/Unix/Command/_bogofilter
@@ -0,0 +1,57 @@
+#compdef bogoutil
+
+local ret bogotokens
+
+_bogoutil_caching_policy () {
+
+  # rebuild if cache is more than a week old
+  oldp=( "$1"(mw+1) )
+  (( $#oldp )) && return 0
+
+  return 1
+}
+
+_bogofilter() {
+  _arguments -C \
+  	'-v[verbose]' \
+  	'-n[replace non-ASCII characters]' \
+  	'-D[redirect debug output to stdout]' \
+  	'-a[acceptable token age]:date or day count' \
+  	'-c[acceptable count]:count threshold' \
+  	'-s[acceptable size range]:min-max range' \
+  	'-y[date for when unknown]:date' \
+  	'-I[input file]:input file:_files' \
+  	'-x[debug flags]:debug flags:' \
+  	'-d[print contents of db]:database:_files -g "*.db"' \
+  	'-l[load file into db]:textfile:_files' \
+  	'-m[perform maintenance functions]' \
+  	'-w[display token information]:database file or directory:_files' \
+  	'-w[display token probability information]:database file or directory:_files' \
+  	'-H[print histogram]' \
+  	'(-R)-r[recalculate ROBX]' \
+  	'(-r)-R[recalculate and save ROBX]' \
+  	'-h[help]' \
+  	'-V[version]' \
+  	'*:tokens:->tokens' && ret=0
+  
+  zstyle -s ":completion:${curcontext}:" cache-policy update_policy
+  if [[ -z "$update_policy" ]]; then
+    zstyle ":completion:${curcontext}:" cache-policy _bogoutil_caching_policy
+  fi
+  
+  case $state in
+  	(tokens)
+  	if ( [[ -z "$bogotokens" ]] || _cache_invalid bogotokens ) &&
+  	  ! _retrieve_cache bogotokens; then
+  	  bogotokens=(${${(f)"$(_call_program bogoutil bogoutil -d ~/.bogofilter/wordlist.db -c 50)"}%% *})
+  	  _store_cache bogotokens bogotokens
+  	else
+  	  :
+  	fi
+  	  _wanted tokens expl "token" \
+  	     compadd -a bogotokens
+  	;;
+  esac
+}
+
+_bogofilter "$@"