zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: _cdcd
@ 2002-02-14 17:53 Clint Adams
  0 siblings, 0 replies; only message in thread
From: Clint Adams @ 2002-02-14 17:53 UTC (permalink / raw)
  To: zsh-workers

This was written by Gergely Nagy <algernon@debian.org>.

Index: Completion/Unix/Command/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/.distfiles,v
retrieving revision 1.18
diff -u -r1.18 .distfiles
--- Completion/Unix/Command/.distfiles	18 Jan 2002 14:49:02 -0000	1.18
+++ Completion/Unix/Command/.distfiles	14 Feb 2002 17:50:15 -0000
@@ -16,5 +16,5 @@
 _diff         _gs           _make         _psutils      _tin	_apm  _mail
 _last         _loadkeys     _modutils     _ruby         _sysctl _links _samba
 _user_admin   _rsync        _arping	  _spamassassin _mtools       _ifconfig
-_fsh          _chkconfig
+_fsh          _chkconfig    _cdcd
 '
Index: Completion/Unix/Command/_cdcd
===================================================================
RCS file: Completion/Unix/Command/_cdcd
diff -N Completion/Unix/Command/_cdcd
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Unix/Command/_cdcd	14 Feb 2002 17:50:15 -0000
@@ -0,0 +1,101 @@
+#compdef cdcd
+
+typeset -A opt_args
+
+_cdcd_tracks ()
+{
+    cdcd info | sed -e 1,2d -e 4d -e "s,Total tracks: *\([0-9]\+\).*,\1,"
+}
+
+_cdcd_track_list ()
+{
+    seq 1 $(_cdcd_tracks)
+}
+
+_cdcd_track_list_verbose ()
+{
+    cdcd tracks | grep "^[ 0-9]\+:" | sed -e 's,^ *\([0-9]\+\):[ >]*. *[^ ]* *\(.*\) \+,\1\\\:\"\2\",'
+}
+
+_cdcd_commands ()
+{
+    _arguments \
+	':cdcd command:((
+	play\:"play a track"
+	stop\:"stop plating"
+	open\:"eject the CD-ROM tray"
+	eject\:"eject the CD-ROM tray"
+	close\:"close the CD-ROM tray"
+	pause\:"pause playing"
+	resume\:"resume playing"
+	ff\:"fast forward"
+	rew\:"rewind"
+	next\:"advance one track"
+	prev\:"return to previous track"
+	getvol\:"get current volume settings"
+	setvol\:"set volume settings"
+	status\:"get numerical data regarding the CD status"
+	info\:"short information about the CD"
+	tracks\:"list all tracks on the CD"
+	rndplay\:"play a random track"
+	list\:"list all CDs in a CD-ROM changer"
+	slot\:"changes the current CD in the CD-ROM changer"
+	edit\:"edit information about the disc"
+	ext\:"Extended information about the disc"
+	refresh\:"refresh the information about the CD from a CDDB server"
+	device\:"change the CD-ROM device cdcd will use"
+	verbose\:"toggle verbosity"
+	sites\:"edit the server list"
+	access\:"configure cddb access method"
+	help\:"display a help message"
+	))'
+}
+
+if (( CURRENT == 2 )); then
+    _cdcd_commands
+else
+    shift words
+    (( --CURRENT ))
+    case "$words[1]" in
+	# sub-commands with no args
+	stop|open|eject|close|pause|resume|next|prev|getvol)
+	    ;;
+	status|info|tracks|rndplay|list|slot|refresh)
+	    ;;
+	# sub-commands with args that cannot be completed
+	ff|rew|setvol)
+	    ;;
+	# sub-commands that do not work as expected
+	access|edit|sites)
+	    ;;
+	# completeable sub-commands
+	verbose)
+	    _arguments \
+		':verbose subcommand:((
+		on\:"turn verbosity on"
+		off\:"turn verbosity off"))'
+	    ;;
+	ext)
+	    _arguments \
+		":ext subcommand:((
+		disc\:\"extra information about the disc\"
+		$(_cdcd_track_list)))"
+	    ;;
+	device)
+	    compadd "$expl[@]" /dev/cd* /dev/cd*/*
+	    ;;
+	play)
+	    if (( CURRENT == 2 )); then
+		_arguments ":play subcommand:((
+		$(_cdcd_track_list_verbose)))"
+	    else
+		shift words
+		(( --CURRENT ))
+		_arguments ":play subcommand2:((
+		$(_cdcd_track_list_verbose)))"
+	    fi
+	    ;;
+	help)
+	    _cdcd_commands;;
+    esac
+fi


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-02-14 17:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-14 17:53 PATCH: _cdcd Clint Adams

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).