#compdef irssi
#
# Written by Istvan Sebestyen <stevee@alphanet.ch>
# Last Modified: Fri Feb 22 11:12:43 CET 2002
#
# Minor fixes by Gergely Nagy <algernon@debian.org>
#
#=========================================================#
# Howto Install:
#
# just make a directory for the compdef files and move 
# this file in it:
#
# $ mkdir ~/.zsh
# $ mv _irssi ~/.zsh/
#
# Put the following lines to your .zshrc:
#
# fpath=($fpath ~/.zsh)   # if your compdef dir is ~/.zsh
# autoload -U compinit
# compinit
#
# finally logout and login.
#=========================================================#

typeset -A opt_args

local expl _servers _ports _nick _config _connect _help

_servers() {
		local a
		a=($(grep "\(^[{ 	]*address\)\|\([{ 	]address\)[ 	]*=" ~/.irssi/config | sed -e "s,^.*address *= *\"\([^\"]\+\).*,\1 ,g"))
		compadd -x 'use "--help" to get descriptions' $a[@]
		}

_ports() {
		local a
		a=($(grep "\(^[{ 	]*port\)\|\([{ 	]port\)[ 	]*=" ~/.irssi/config | sed -e "s,^.*port *= *\"\([^\"]\+\).*,\1,g"))
		compadd -x 'use "--help" to get descriptions' $a[@]
		}

_nick() {
		local a
		a=($(grep "\(^[{ 	]*nick\)\|\([{ 	]nick\)\|\([{ 	]alternate_nick\)\|\(^[{ 	]*alternate_nick\)[ 	]*=" ~/.irssi/config | sed -e "s,^.*nick *= *\"\([^\"]\+\).*,\1,g"))
		compadd -x 'use "--help" to get descriptions' $a[@]
		}

_arguments -C -s \
	"--config=[config file]:config:_files" \
	"--home=[home dir location]:home:_dir_list" \
	"-c[connect to servers]:irc servers: _servers" \
	"--connect=[connect to servers]:irc servers: _servers" \
	'-w[password]' \
	'--password=[password]' \
	"-p[specify a port]:port: _ports" \
	"--port=[specify a port]:port: _ports" \
	'-![disable autoconnect]' \
	'--noconnect[disable autoconnect]' \
	"-n[set nick name]:nick: _nick" \
	"--nick=[set nick name]:nick: _nick" \
	'-h[hostname]' \
	'--hostname=[hostname]' \
	'-v[version]' \
	'--version[version]' \
	'-?[help message]' \
	'--help[help message]' \
	'--usage[display usage]' \
