From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 379B01F454 for ; Wed, 6 Nov 2019 06:52:50 +0000 (UTC) Received: from localhost ([::1]:53126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSFBQ-00026M-NK for e@80x24.org; Wed, 06 Nov 2019 01:52:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51595) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSFBN-00025v-A7 for dtas-all@nongnu.org; Wed, 06 Nov 2019 01:52:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iSFBL-0007ws-3j for dtas-all@nongnu.org; Wed, 06 Nov 2019 01:52:45 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:37770) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iSFBK-0007vE-QJ for dtas-all@nongnu.org; Wed, 06 Nov 2019 01:52:43 -0500 Received: by mail-wr1-x42a.google.com with SMTP id t1so18411263wrv.4 for ; Tue, 05 Nov 2019 22:52:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=i057KX8IJFwxr3BJHrU2XXVUF/A/MQilxw31Pw37ZFc=; b=ewOHG+35LlmbIt4IMWCdLZDVIXrCxz0Ur/4PgIFlBtIoWMPL+W5TfxDrTbcH4KDthU 9dPQWC3j+NyXVz459+YA9zwlz0R4TglOBuCcc7ToRMBouJT89gB3nS2yVaHCURPXou8C vzcHD3V0CcBlweSYwZgFs5E0qBK21UTKVmth8TdoXygTkjSvHrmKgicvlNTUJZqqOMnB FXkXQVwXOyVEllf4c+SBbprHCVnNg+Fk1pv8BLP9u5Jj2OcOWgCJQq7GzB0CzXsS2vvH YVU/OZ0cpXLj0GwHEQwTtdFGaZzZ9se//6NwBrS/mncgZ7qVgQKQm5T5U8u3kp7yCZSD RLOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=i057KX8IJFwxr3BJHrU2XXVUF/A/MQilxw31Pw37ZFc=; b=Y7Npjj3WPUtMA4ZDFfRfC0TVmxIafnAXBIrEjFXTJxVbN8jwOlEv6OJkjV2kqb5Zqr EdU28bwmYE8AzKcH1tGi91FrJy+BSPfA7ltBYGc42eNzoTfCkIYvT+qvZDV4WxoyeAlW qrlkWFrFckF15yW+zd/0o8CVsC+s1YyWmId3GhCiBJoypbvKIpZ5B1I+Q8Ge3oWRDCDD n2KMxGjV6guXVXFK8stWUfRxC/KR5WyDYhsQZQrmRAJ9DMNrl7EzmYehpUQVWRp7Rv+Z WUJQf4/GjMKGV6OITjseYfXzEO5/u6YMpn2NT7Wo+EHJUr3V2vJNvV7su8pARg2/JLBQ 1u+Q== X-Gm-Message-State: APjAAAVBvhULEYJzMr05CCHd1FAXEDZ8EUXs5Bhv/Bg6Vmm8P7CcECPd sHc9iek4yI06zT/jXOfCkuYf/kr2 X-Google-Smtp-Source: APXvYqwLupyI/Cs0dOyNq8jOch4H5EYTiDLiHbk28jpBQ0CZz/tf69QeHmXwKxXELhJgbCy7h48fbQ== X-Received: by 2002:adf:f1c7:: with SMTP id z7mr1114351wro.355.1573023160551; Tue, 05 Nov 2019 22:52:40 -0800 (PST) Received: from localhost.localdomain (188.30.155.221.threembb.co.uk. [188.30.155.221]) by smtp.gmail.com with ESMTPSA id a10sm3382381wrg.0.2019.11.05.22.52.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 22:52:39 -0800 (PST) From: James Rowe To: dtas-all@nongnu.org Subject: [PATCH] Add zsh completion support Date: Wed, 6 Nov 2019 06:52:26 +0000 Message-Id: <20191106065227.22210-1-jnrowe@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42a X-BeenThere: dtas-all@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: duct tape audio suite List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Rowe Errors-To: dtas-all-bounces+e=80x24.org@nongnu.org Sender: "dtas-all" 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