everything related to duct tape audio suite (dtas)
 help / color / mirror / code / Atom feed
From: James Rowe <jnrowe@gmail.com>
To: dtas-all@nongnu.org
Cc: James Rowe <jnrowe@gmail.com>
Subject: [PATCH] Add zsh completion support
Date: Wed,  6 Nov 2019 06:52:26 +0000	[thread overview]
Message-ID: <20191106065227.22210-1-jnrowe@gmail.com> (raw)

This adds completion support for all the current commands, including
completion for sink and source names where they are used.

---

  [My apologies that it took me a few days to get around to updating
this, and thanks for the push to reach a little further ;)]

  This patch supersedes the version I attached earlier. Differences to
the previous version:

* All the commands where completion makes sense are supported,
* The capitalisation and formatting patterns of zsh’s included rules are
  used.

Thanks,

James

 examples/zsh-completion/README           |   3 +
 examples/zsh-completion/_dtas-archive    |  16 ++++
 examples/zsh-completion/_dtas-ctl        | 114 +++++++++++++++++++++++
 examples/zsh-completion/_dtas-cueedit    |   7 ++
 examples/zsh-completion/_dtas-enq        |   7 ++
 examples/zsh-completion/_dtas-mlib       |  29 ++++++
 examples/zsh-completion/_dtas-msinkctl   |   8 ++
 examples/zsh-completion/_dtas-partstats  |   7 ++
 examples/zsh-completion/_dtas-sinkedit   |  11 +++
 examples/zsh-completion/_dtas-sourceedit |  11 +++
 examples/zsh-completion/_dtas-splitfx    |  17 ++++
 examples/zsh-completion/_dtas-tl         |  52 +++++++++++
 examples/zsh-completion/_dtas-xdelay     |  17 ++++
 13 files changed, 299 insertions(+)
 create mode 100644 examples/zsh-completion/README
 create mode 100644 examples/zsh-completion/_dtas-archive
 create mode 100644 examples/zsh-completion/_dtas-ctl
 create mode 100644 examples/zsh-completion/_dtas-cueedit
 create mode 100644 examples/zsh-completion/_dtas-enq
 create mode 100644 examples/zsh-completion/_dtas-mlib
 create mode 100644 examples/zsh-completion/_dtas-msinkctl
 create mode 100644 examples/zsh-completion/_dtas-partstats
 create mode 100644 examples/zsh-completion/_dtas-sinkedit
 create mode 100644 examples/zsh-completion/_dtas-sourceedit
 create mode 100644 examples/zsh-completion/_dtas-splitfx
 create mode 100644 examples/zsh-completion/_dtas-tl
 create mode 100644 examples/zsh-completion/_dtas-xdelay

diff --git a/examples/zsh-completion/README b/examples/zsh-completion/README
new file mode 100644
index 0000000..89b3afd
--- /dev/null
+++ b/examples/zsh-completion/README
@@ -0,0 +1,3 @@
+To use the completion functions defined in this directory either: add
+the completions you wish to use to a directory in your $fpath, or add
+this directory's path to $fpath *prior* to calling compinit.
diff --git a/examples/zsh-completion/_dtas-archive b/examples/zsh-completion/_dtas-archive
new file mode 100644
index 0000000..2bfdf7e
--- /dev/null
+++ b/examples/zsh-completion/_dtas-archive
@@ -0,0 +1,16 @@
+#compdef dtas-archive
+
+# To the extent possible under law, James Rowe has waived all copyright and
+# related or neighboring rights to this example.
+
+_arguments -S \
+    "--type=[file type]" \
+    "--compression=[compression factor for sox]:select compression:({0..8})" \
+    "--jobs=[number of jobs]: :_guard '[0-9]#' value" \
+    "--stats[save stats on the file]" \
+    "--keep-going[continue after error]" \
+    "--dry-run[only print commands, do not run them]" \
+    "--repeat=[number of times to check]: :_guard '[0-9]#' value" \
+    "--help[display help message]" \
+    ":select source:_files" \
+    ":select destination:_files"
diff --git a/examples/zsh-completion/_dtas-ctl b/examples/zsh-completion/_dtas-ctl
new file mode 100644
index 0000000..d82533b
--- /dev/null
+++ b/examples/zsh-completion/_dtas-ctl
@@ -0,0 +1,114 @@
+#compdef dtas-ctl
+
+# To the extent possible under law, James Rowe has waived all copyright and
+# related or neighboring rights to this example.
+
+_arguments \
+    ':dtas-ctl command:((
+        cd\:"change the current working directory of the player"
+        clear\:"clear current queue"
+        cue\:"display the index/offsets of the embedded CUE sheet"
+        current\:"output information about the current track/command in YAML"
+        enq\:"enqueue the given FILENAME for playback"
+        enq-cmd\:"run the following command for playback"
+        env\:"set/unset environment variables"
+        format\:"configure the format between source and sink"
+        pause\:"pause playback"
+        play\:"restart playback from pause"
+        play_pause\:"toggle the play/pause state"
+        queue\ cat\:"dump the contents of the queue as YAML"
+        restart\:"restarts all processes in the current pipeline"
+        rg\:"configure ReplayGain support"
+        seek\:"seek the current track to a specified time"
+        skip\:"abort current track/command"
+        sink\:"control sinks"
+        source\:"control sources"
+        state\ dump\:"immediately dump the state of the player"
+        tl\:"control tracklist"
+        trim\:"limits playback of all tracks in the tracklist"
+        watch\:"adds the client to the passive watch list for notifications"
+    ))' \
+    "*::subcmd:->subcmd" && return 0
+
+case "$words[1]" in
+(cd)
+    _arguments \
+        ":select dir:_path_files -/"
+    ;;
+(cue)
+    _arguments \
+        ':dtas-ctl command:((
+            next\:"skip to the next cue sheet offset"
+            prev\:"skip to the previous cue sheet offset"
+            goto\:"go to the cue index"
+            seek\:"seek within the current cue index"
+        ))'
+    ;;
+(enq)
+    _arguments \
+        "*:select file:_files"
+    ;;
+(format)
+    _arguments \
+        '*:dtas-ctl format command:((
+            channels\:"number of channels to use internally"
+            endian\:"change endianess"
+            bits\:"sample precision"
+            rate\:"sample rate of audio"
+            type\:"change the raw PCM format"
+        ))'
+    ;;
+(seek)
+    _arguments \
+        ":select track:_guard '[0-9]#' 'track number'"
+    ;;
+(sink)
+    _arguments \
+        ':sink subcommand:((
+            ls\:"list names of current sinks"
+            cat\:"dump SINKNAME config in YAML"
+            rm\:"remove SINKNAME"
+            ed\:"create/edit SINKNAME"
+        ))'
+    ;;
+(source)
+    _arguments \
+        ':source subcommand:((
+            cat\:"dump the current source command and env in YAML"
+            ed\:"edit the source parameters"
+            ls\:"dump the names of sources sorted by tryorder"
+            restart\:"restart the current source command"
+        ))'
+    ;;
+(state dump)
+    _arguments \
+        ":select file:_files"
+    ;;
+(tl)
+    _arguments \
+        ':tl subcommand:((
+            add\:"add files to the tracklist"
+            clear\:"clear current tracklist"
+            consume\:"show/or change consume status of the tracklist"
+            current\:"display the pathname to the currently playing track"
+            current-id\:"display the TRACKID of the currently playing track"
+            remove\:"remove the track with the given TRACKID from the track list"
+            get\:"returns a list of TRACKIDS mapped to shell-escaped filenames"
+            goto\:"plays the given TRACKID"
+            max\:"sets or gets the maximum number of tracks allowed in the tracklist"
+            next\:"jump to the next track in the tracklist"
+            prev\:"jump to the previous track in the tracklist"
+            repeat\:"show/or change repeat status of the tracklist"
+            shuffle\:"show/or change the current shuffle status of the tracklist"
+            swap\:"swaps the positions of two tracks"
+            tracks\:"returns a list of all TRACKIDS in the tracklist"
+        ))'
+    ;;
+(trim)
+    _arguments \
+        ":select beginning" \
+        ":select end"
+    ;;
+(*)
+    ;;
+esac
diff --git a/examples/zsh-completion/_dtas-cueedit b/examples/zsh-completion/_dtas-cueedit
new file mode 100644
index 0000000..ac87822
--- /dev/null
+++ b/examples/zsh-completion/_dtas-cueedit
@@ -0,0 +1,7 @@
+#compdef dtas-cueedit
+
+# To the extent possible under law, James Rowe has waived all copyright and
+# related or neighboring rights to this example.
+
+_arguments \
+    ':select file:_files -g "*.flac"'
diff --git a/examples/zsh-completion/_dtas-enq b/examples/zsh-completion/_dtas-enq
new file mode 100644
index 0000000..a8f9c3f
--- /dev/null
+++ b/examples/zsh-completion/_dtas-enq
@@ -0,0 +1,7 @@
+#compdef dtas-enq
+
+# To the extent possible under law, James Rowe has waived all copyright and
+# related or neighboring rights to this example.
+
+_arguments \
+    "*:select file:_files"
diff --git a/examples/zsh-completion/_dtas-mlib b/examples/zsh-completion/_dtas-mlib
new file mode 100644
index 0000000..24418ea
--- /dev/null
+++ b/examples/zsh-completion/_dtas-mlib
@@ -0,0 +1,29 @@
+#compdef dtas-mlib
+
+# To the extent possible under law, James Rowe has waived all copyright and
+# related or neighboring rights to this example.
+#
+_arguments \
+    "--database=[database]:select file:_files" \
+    "--force[force updates]" \
+    "--help[display help message]" \
+    ':dtas-mlib action:((
+            dump\:"dump database"
+            search\:"search database"
+            stats\:"display statistics"
+            update\:"migrate database"
+        ))' \
+    "*::subcmd:->subcmd" && return 0
+
+case "$words[1]" in
+(dump|update)
+    _arguments -S \
+        ":select directory:_path_files -/"
+    ;;
+(search)
+    _arguments -S \
+        "*:search term:"
+    ;;
+(*)
+    ;;
+esac
diff --git a/examples/zsh-completion/_dtas-msinkctl b/examples/zsh-completion/_dtas-msinkctl
new file mode 100644
index 0000000..941c23b
--- /dev/null
+++ b/examples/zsh-completion/_dtas-msinkctl
@@ -0,0 +1,8 @@
+#compdef dtas-msinkctl
+
+# To the extent possible under law, James Rowe has waived all copyright and
+# related or neighboring rights to this example.
+
+_arguments \
+    "1:select action:(active{,-{set,add,sub}} nonblock)" \
+    "*:select sink:($(dtas-ctl sink ls 2> /dev/null))"
diff --git a/examples/zsh-completion/_dtas-partstats b/examples/zsh-completion/_dtas-partstats
new file mode 100644
index 0000000..9460684
--- /dev/null
+++ b/examples/zsh-completion/_dtas-partstats
@@ -0,0 +1,7 @@
+#compdef dtas-partstats
+
+# To the extent possible under law, James Rowe has waived all copyright and
+# related or neighboring rights to this example.
+
+_arguments \
+    ":select file:_files"
diff --git a/examples/zsh-completion/_dtas-sinkedit b/examples/zsh-completion/_dtas-sinkedit
new file mode 100644
index 0000000..be6de53
--- /dev/null
+++ b/examples/zsh-completion/_dtas-sinkedit
@@ -0,0 +1,11 @@
+#compdef dtas-sinkedit
+
+# To the extent possible under law, James Rowe has waived all copyright and
+# related or neighboring rights to this example.
+
+_arguments \
+    "--no-watch[disable inotify support]" \
+    "--dry-run[only print commands, do not run them]" \
+    "--verbose[print out commands sent to change the sink]" \
+    "--help[display help message]" \
+    ":select sink:($(dtas-ctl sink ls 2> /dev/null))"
diff --git a/examples/zsh-completion/_dtas-sourceedit b/examples/zsh-completion/_dtas-sourceedit
new file mode 100644
index 0000000..56da661
--- /dev/null
+++ b/examples/zsh-completion/_dtas-sourceedit
@@ -0,0 +1,11 @@
+#compdef dtas-sourceedit
+
+# To the extent possible under law, James Rowe has waived all copyright and
+# related or neighboring rights to this example.
+
+_arguments \
+    "--no-watch[disable inotify support]" \
+    "--dry-run[only print commands, do not run them]" \
+    "--verbose[print out commands sent to change the source]" \
+    "--help[display help message]" \
+    ":select source:($(dtas-ctl source ls 2> /dev/null))"
diff --git a/examples/zsh-completion/_dtas-splitfx b/examples/zsh-completion/_dtas-splitfx
new file mode 100644
index 0000000..dfebb64
--- /dev/null
+++ b/examples/zsh-completion/_dtas-splitfx
@@ -0,0 +1,17 @@
+#compdef dtas-splitfx
+
+# To the extent possible under law, James Rowe has waived all copyright and
+# related or neighboring rights to this example.
+
+_arguments -S \
+    "--dry-run[only print commands, do not run them]" \
+    "--jobs=[number of jobs]: :_guard '[0-9]#' value" \
+    "--no-dither[don't apply sox dithering]" \
+    "--outdir=[select output directory]:select directory:_path_files -/" \
+    "--compression=[compression factor for sox]:select compression:({0..8})" \
+    "--rate=[sample rate of audio]:select sample rate:(22050 44100 48000)" \
+    "--bits=[sample precision]:select precision:(8 16 24)" \
+    "--trim=[sections of audio to cut]:select sections:_guard '[0-9,]#' 'value'" \
+    "--sox-pipe[use as pipeline]" \
+    '1:select splitfx file:_files -g "*.yml"' \
+    "*:select file:_files"
diff --git a/examples/zsh-completion/_dtas-tl b/examples/zsh-completion/_dtas-tl
new file mode 100644
index 0000000..8e2b098
--- /dev/null
+++ b/examples/zsh-completion/_dtas-tl
@@ -0,0 +1,52 @@
+#compdef dtas-tl
+
+# To the extent possible under law, James Rowe has waived all copyright and
+# related or neighboring rights to this example.
+
+_arguments \
+    ':dtas-tl command:((
+       aac\:"add tracks after current track in the tracklist"
+       addhead\:"add tracks to the beginning of the tracklist"
+       addtail\:"add tracks to the end of the tracklist"
+       consume\:"enabling \"consume\" mode"
+       current\:"display the current track"
+       current-id\:"display the track of the current track"
+       cat\:"display a tracklist"
+       clear\:"remove all tracks from the tracklist"
+       edit\:"spawn an editor to allow editing the tracklist"
+       goto\:"play track immediately"
+       reto\:"play track matching regular expression"
+       next\:"play the next track in the tracklist"
+       prev\:"play the previous track in the tracklist"
+       repeat\:"control track repeating"
+       shuffle\:"control playback randomization"
+    ))' \
+    "*::subcmd:->subcmd" && return 0
+
+case "$words[1]" in
+(aac|addtail)
+    _arguments \
+        ":select file:_files"
+    ;;
+(addhead)
+    _arguments \
+        "*:select file:_files"
+    ;;
+(consume|repeat|shuffle)
+    _arguments \
+        ":select state:(true false)"
+    ;;
+(goto)
+    _arguments \
+        ":select track:($(dtas-ctl tl tracks 2> /dev/null))"
+    ;;
+(reto)
+    _arguments \
+        "-F[use fixed strings]" \
+        "-i[ignore case]" \
+        ":search term" \
+        ":select beginning"
+    ;;
+(*)
+    ;;
+esac
diff --git a/examples/zsh-completion/_dtas-xdelay b/examples/zsh-completion/_dtas-xdelay
new file mode 100644
index 0000000..356537d
--- /dev/null
+++ b/examples/zsh-completion/_dtas-xdelay
@@ -0,0 +1,17 @@
+#compdef dtas-xdelay
+
+# To the extent possible under law, James Rowe has waived all copyright and
+# related or neighboring rights to this example.
+
+_arguments -S \
+    "--crossover-frequency=[frequency at which to set the crossover]: :_guard '[0-9]#' frequency" \
+    "--lowpass-delay[delay the lowpass frequency instead of the highpass one]" \
+    "--channels=[number of channels]:select channels:(1 2)" \
+    "--rate=[sample rate of audio]:select sample rate:(22050 44100 48000)" \
+    "--type=[file type]:select output type:($(sox --help 2> /dev/null | sed -n '/AUDIO FILE FORMATS/s/.*: //p'))" \
+    "--dry-run[only print commands, do not run them]" \
+    "--lowpass=[Custom format string for lowpass filter]" \
+    "--highpass=[Custom format string for highpass filter]" \
+    ":select input1:_files" \
+    ":select input2:_files" \
+    ":select delay:_guard '[0-9]#' delay"
-- 
2.20.1



             reply	other threads:[~2019-11-06  6:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-06  6:52 James Rowe [this message]
2019-11-09  9:21 ` Eric Wong
2019-11-09 17:53   ` James Rowe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://80x24.org/dtas/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191106065227.22210-1-jnrowe@gmail.com \
    --to=jnrowe@gmail.com \
    --cc=dtas-all@nongnu.org \
    --subject='Re: [PATCH] Add zsh completion support' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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

	../../dtas.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).