use builtin; use str; set edit:completion:arg-completer[rsp] = {|@words| fn spaces {|n| builtin:repeat $n ' ' | str:join '' } fn cand {|text desc| edit:complex-candidate $text &display=$text' '(spaces (- 14 (wcswidth $text)))$desc } var command = 'rsp' for word $words[1..-1] { if (str:has-prefix $word '-') { break } set command = $command';'$word } var completions = [ &'rsp'= { cand -h 'Print help' cand --help 'Print help' cand start-daemon 'Start the daemon' cand stop-daemon 'Stop the daemon' cand restart 'Restart the daemon (kill existing and start new)' cand play 'Play a track, album, or artist' cand pause 'Pause playback' cand resume 'Resume playback' cand toggle 'Toggle play/pause' cand stop 'Stop playback' cand next 'Skip to next track' cand previous 'Skip to previous track' cand volume 'Set volume (0-100)' cand shuffle 'Shuffle mode' cand queue 'Queue management' cand status 'Show player status' cand scan 'Scan music paths to populate database' cand settings 'Settings management' cand completions 'Generate shell completions (developer only)' cand help 'Print this message or the help of the given subcommand(s)' } &'rsp;start-daemon'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;stop-daemon'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;restart'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;play'= { cand -i 'Add after current track and skip to it' cand --now 'Add after current track and skip to it' cand -n 'Add to queue after current track (don''t skip)' cand --next 'Add to queue after current track (don''t skip)' cand -h 'Print help' cand --help 'Print help' } &'rsp;pause'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;resume'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;toggle'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;stop'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;next'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;previous'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;volume'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;shuffle'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;queue'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;status'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;scan'= { cand --paths 'paths' cand --force 'force' cand -h 'Print help' cand --help 'Print help' } &'rsp;settings'= { cand -h 'Print help' cand --help 'Print help' cand get 'Get a setting value' cand set 'Set a setting value' cand list 'List all settings' cand unset 'Unset a setting' cand help 'Print this message or the help of the given subcommand(s)' } &'rsp;settings;get'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;settings;set'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;settings;list'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;settings;unset'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;settings;help'= { cand get 'Get a setting value' cand set 'Set a setting value' cand list 'List all settings' cand unset 'Unset a setting' cand help 'Print this message or the help of the given subcommand(s)' } &'rsp;settings;help;get'= { } &'rsp;settings;help;set'= { } &'rsp;settings;help;list'= { } &'rsp;settings;help;unset'= { } &'rsp;settings;help;help'= { } &'rsp;completions'= { cand -h 'Print help' cand --help 'Print help' } &'rsp;help'= { cand start-daemon 'Start the daemon' cand stop-daemon 'Stop the daemon' cand restart 'Restart the daemon (kill existing and start new)' cand play 'Play a track, album, or artist' cand pause 'Pause playback' cand resume 'Resume playback' cand toggle 'Toggle play/pause' cand stop 'Stop playback' cand next 'Skip to next track' cand previous 'Skip to previous track' cand volume 'Set volume (0-100)' cand shuffle 'Shuffle mode' cand queue 'Queue management' cand status 'Show player status' cand scan 'Scan music paths to populate database' cand settings 'Settings management' cand completions 'Generate shell completions (developer only)' cand help 'Print this message or the help of the given subcommand(s)' } &'rsp;help;start-daemon'= { } &'rsp;help;stop-daemon'= { } &'rsp;help;restart'= { } &'rsp;help;play'= { } &'rsp;help;pause'= { } &'rsp;help;resume'= { } &'rsp;help;toggle'= { } &'rsp;help;stop'= { } &'rsp;help;next'= { } &'rsp;help;previous'= { } &'rsp;help;volume'= { } &'rsp;help;shuffle'= { } &'rsp;help;queue'= { } &'rsp;help;status'= { } &'rsp;help;scan'= { } &'rsp;help;settings'= { cand get 'Get a setting value' cand set 'Set a setting value' cand list 'List all settings' cand unset 'Unset a setting' } &'rsp;help;settings;get'= { } &'rsp;help;settings;set'= { } &'rsp;help;settings;list'= { } &'rsp;help;settings;unset'= { } &'rsp;help;completions'= { } &'rsp;help;help'= { } ] $completions[$command] }