* zsh completion for dtas-ctl
@ 2019-11-03 0:35 James Rowe
2019-11-03 1:07 ` Eric Wong
0 siblings, 1 reply; 4+ messages in thread
From: James Rowe @ 2019-11-03 0:35 UTC (permalink / raw)
To: dtas-all
[-- Attachment #1.1: Type: text/plain, Size: 729 bytes --]
Hi,
Thanks to rb_optparse.zsh¹ completion is available for many of the
dtas commands, however this isn't the case for dtas-ctl as its interface
isn't built on optparse.
Attached is the first cut of a zsh completion script for dtas-ctl. It
doesn't include all the features, and it really isn't as smart as it
should be. It does Work For Me™. I've pasted the CC0 header on to it
should you wish to add it to the examples/ directory.
The obvious improvements are that it should be automatically
generated, probably from the player protocol manpage or some such.
Thanks,
James
1. https://github.com/ruby/ruby/blob/master/misc/rb_optparse.zsh
--
☒ Vote to destroy email signatures today!
[-- Attachment #1.2: _dtas-ctl --]
[-- Type: text/plain, Size: 4668 bytes --]
#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 \
'1: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|state dump)
_arguments \
':select file:_files'
;;
(format)
_arguments \
'channels=[Number of channels to use internally.]' \
'endian=[Change endianess.]:select endianess:(big little swap)' \
'bits=[Sample precision.]:select precision:(16 bypass)' \
'rate=[Sample rate of audio.]:select sample rate:(44100 48000 bypass)' \
'type=[Change the raw PCM format.]:select raw PCM format:(s16 s24 s32 u16 u24 u32 f32 f64)'
;;
(rg)
_arguments \
'fallback_gain=[Adjust the volume by this level for tracks.]:select adjustment:_guard "-?[0-9]#" "dB value"' \
'fallback_track=[When in album_gain mode, fallback to track_gain.]:select option:(true false)' \
'mode=[Controls the ReplayGain tag to use.]:(album_gain track_gain track_norm album_norm off)' \
'preamp=[Adjust the album_gain or track_gain.]:select adjustment:_guard "-?[0-9]#" "dB value"' \
'norm_level=[Control the level to normalize.]:select level:_guard "-?[0-9]#" "dB value"'
;;
(seek)
_arguments \
'1: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."
))'
;;
(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 \
'1:select beginning' \
'2:select end'
;;
(*)
;;
esac
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: zsh completion for dtas-ctl
2019-11-03 0:35 zsh completion for dtas-ctl James Rowe
@ 2019-11-03 1:07 ` Eric Wong
2019-11-04 2:19 ` Eric Wong
0 siblings, 1 reply; 4+ messages in thread
From: Eric Wong @ 2019-11-03 1:07 UTC (permalink / raw)
To: James Rowe; +Cc: dtas-all
James Rowe <jnrowe@gmail.com> wrote:
> Hi,
>
> Thanks to rb_optparse.zsh¹ completion is available for many of the
> dtas commands, however this isn't the case for dtas-ctl as its interface
> isn't built on optparse.
>
> Attached is the first cut of a zsh completion script for dtas-ctl. It
> doesn't include all the features, and it really isn't as smart as it
> should be. It does Work For Me™. I've pasted the CC0 header on to it
> should you wish to add it to the examples/ directory.
Wow, thank you for your time and effort in doing this!
I'm not a zsh user myself, but probably a examples/zsh-completion/
directory in preparation for other commands?
> The obvious improvements are that it should be automatically
> generated, probably from the player protocol manpage or some such.
Yes, that would be nice, but see below.
>
> 1. https://github.com/ruby/ruby/blob/master/misc/rb_optparse.zsh
> #compdef dtas-ctl
<snip>
> # 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."
<snip>
> ))' \
> '*::subcmd:->subcmd' && return 0
>
> case "$words[1]" in
> (cd)
> _arguments \
> ':select dir:_path_files -/'
> ;;
>
> (cue)
> _arguments \
> '1: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."
> ))'
> ;;
As a non-zsh user, this seems easy-to-follow, understand, and
maybe build a standalone-parser for. So I'm kinda wondering
if a manpage could be generated from this, instead; along
with completions for bash and maybe other shells.
But it could also be a lot of work, so no obligations to do
this :)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-11-04 9:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-03 0:35 zsh completion for dtas-ctl James Rowe
2019-11-03 1:07 ` Eric Wong
2019-11-04 2:19 ` Eric Wong
2019-11-04 9:36 ` James Rowe
Code repositories for project(s) associated with this public inbox
https://80x24.org/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).