diff options
Diffstat (limited to '')
| -rw-r--r-- | completions/rsp.powershell | 280 |
1 files changed, 280 insertions, 0 deletions
diff --git a/completions/rsp.powershell b/completions/rsp.powershell new file mode 100644 index 0000000..58db681 --- /dev/null +++ b/completions/rsp.powershell | |||
| @@ -0,0 +1,280 @@ | |||
| 1 | |||
| 2 | using namespace System.Management.Automation | ||
| 3 | using namespace System.Management.Automation.Language | ||
| 4 | |||
| 5 | Register-ArgumentCompleter -Native -CommandName 'rsp' -ScriptBlock { | ||
| 6 | param($wordToComplete, $commandAst, $cursorPosition) | ||
| 7 | |||
| 8 | $commandElements = $commandAst.CommandElements | ||
| 9 | $command = @( | ||
| 10 | 'rsp' | ||
| 11 | for ($i = 1; $i -lt $commandElements.Count; $i++) { | ||
| 12 | $element = $commandElements[$i] | ||
| 13 | if ($element -isnot [StringConstantExpressionAst] -or | ||
| 14 | $element.StringConstantType -ne [StringConstantType]::BareWord -or | ||
| 15 | $element.Value.StartsWith('-') -or | ||
| 16 | $element.Value -eq $wordToComplete) { | ||
| 17 | break | ||
| 18 | } | ||
| 19 | $element.Value | ||
| 20 | }) -join ';' | ||
| 21 | |||
| 22 | $completions = @(switch ($command) { | ||
| 23 | 'rsp' { | ||
| 24 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 25 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 26 | [CompletionResult]::new('start-daemon', 'start-daemon', [CompletionResultType]::ParameterValue, 'Start the daemon') | ||
| 27 | [CompletionResult]::new('stop-daemon', 'stop-daemon', [CompletionResultType]::ParameterValue, 'Stop the daemon') | ||
| 28 | [CompletionResult]::new('restart', 'restart', [CompletionResultType]::ParameterValue, 'Restart the daemon (kill existing and start new)') | ||
| 29 | [CompletionResult]::new('play', 'play', [CompletionResultType]::ParameterValue, 'Play a track, album, or artist') | ||
| 30 | [CompletionResult]::new('pause', 'pause', [CompletionResultType]::ParameterValue, 'Pause playback') | ||
| 31 | [CompletionResult]::new('resume', 'resume', [CompletionResultType]::ParameterValue, 'Resume playback') | ||
| 32 | [CompletionResult]::new('toggle', 'toggle', [CompletionResultType]::ParameterValue, 'Toggle play/pause') | ||
| 33 | [CompletionResult]::new('stop', 'stop', [CompletionResultType]::ParameterValue, 'Stop playback') | ||
| 34 | [CompletionResult]::new('next', 'next', [CompletionResultType]::ParameterValue, 'Skip to next track') | ||
| 35 | [CompletionResult]::new('previous', 'previous', [CompletionResultType]::ParameterValue, 'Skip to previous track') | ||
| 36 | [CompletionResult]::new('volume', 'volume', [CompletionResultType]::ParameterValue, 'Set volume (0-100)') | ||
| 37 | [CompletionResult]::new('shuffle', 'shuffle', [CompletionResultType]::ParameterValue, 'Shuffle mode') | ||
| 38 | [CompletionResult]::new('queue', 'queue', [CompletionResultType]::ParameterValue, 'Queue management') | ||
| 39 | [CompletionResult]::new('status', 'status', [CompletionResultType]::ParameterValue, 'Show player status') | ||
| 40 | [CompletionResult]::new('scan', 'scan', [CompletionResultType]::ParameterValue, 'Scan music paths to populate database') | ||
| 41 | [CompletionResult]::new('settings', 'settings', [CompletionResultType]::ParameterValue, 'Settings management') | ||
| 42 | [CompletionResult]::new('completions', 'completions', [CompletionResultType]::ParameterValue, 'Generate shell completions (developer only)') | ||
| 43 | [CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)') | ||
| 44 | break | ||
| 45 | } | ||
| 46 | 'rsp;start-daemon' { | ||
| 47 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 48 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 49 | break | ||
| 50 | } | ||
| 51 | 'rsp;stop-daemon' { | ||
| 52 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 53 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 54 | break | ||
| 55 | } | ||
| 56 | 'rsp;restart' { | ||
| 57 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 58 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 59 | break | ||
| 60 | } | ||
| 61 | 'rsp;play' { | ||
| 62 | [CompletionResult]::new('-i', '-i', [CompletionResultType]::ParameterName, 'Add after current track and skip to it') | ||
| 63 | [CompletionResult]::new('--now', '--now', [CompletionResultType]::ParameterName, 'Add after current track and skip to it') | ||
| 64 | [CompletionResult]::new('-n', '-n', [CompletionResultType]::ParameterName, 'Add to queue after current track (don''t skip)') | ||
| 65 | [CompletionResult]::new('--next', '--next', [CompletionResultType]::ParameterName, 'Add to queue after current track (don''t skip)') | ||
| 66 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 67 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 68 | break | ||
| 69 | } | ||
| 70 | 'rsp;pause' { | ||
| 71 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 72 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 73 | break | ||
| 74 | } | ||
| 75 | 'rsp;resume' { | ||
| 76 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 77 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 78 | break | ||
| 79 | } | ||
| 80 | 'rsp;toggle' { | ||
| 81 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 82 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 83 | break | ||
| 84 | } | ||
| 85 | 'rsp;stop' { | ||
| 86 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 87 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 88 | break | ||
| 89 | } | ||
| 90 | 'rsp;next' { | ||
| 91 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 92 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 93 | break | ||
| 94 | } | ||
| 95 | 'rsp;previous' { | ||
| 96 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 97 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 98 | break | ||
| 99 | } | ||
| 100 | 'rsp;volume' { | ||
| 101 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 102 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 103 | break | ||
| 104 | } | ||
| 105 | 'rsp;shuffle' { | ||
| 106 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 107 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 108 | break | ||
| 109 | } | ||
| 110 | 'rsp;queue' { | ||
| 111 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 112 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 113 | break | ||
| 114 | } | ||
| 115 | 'rsp;status' { | ||
| 116 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 117 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 118 | break | ||
| 119 | } | ||
| 120 | 'rsp;scan' { | ||
| 121 | [CompletionResult]::new('--paths', '--paths', [CompletionResultType]::ParameterName, 'paths') | ||
| 122 | [CompletionResult]::new('--force', '--force', [CompletionResultType]::ParameterName, 'force') | ||
| 123 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 124 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 125 | break | ||
| 126 | } | ||
| 127 | 'rsp;settings' { | ||
| 128 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 129 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 130 | [CompletionResult]::new('get', 'get', [CompletionResultType]::ParameterValue, 'Get a setting value') | ||
| 131 | [CompletionResult]::new('set', 'set', [CompletionResultType]::ParameterValue, 'Set a setting value') | ||
| 132 | [CompletionResult]::new('list', 'list', [CompletionResultType]::ParameterValue, 'List all settings') | ||
| 133 | [CompletionResult]::new('unset', 'unset', [CompletionResultType]::ParameterValue, 'Unset a setting') | ||
| 134 | [CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)') | ||
| 135 | break | ||
| 136 | } | ||
| 137 | 'rsp;settings;get' { | ||
| 138 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 139 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 140 | break | ||
| 141 | } | ||
| 142 | 'rsp;settings;set' { | ||
| 143 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 144 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 145 | break | ||
| 146 | } | ||
| 147 | 'rsp;settings;list' { | ||
| 148 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 149 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 150 | break | ||
| 151 | } | ||
| 152 | 'rsp;settings;unset' { | ||
| 153 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 154 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 155 | break | ||
| 156 | } | ||
| 157 | 'rsp;settings;help' { | ||
| 158 | [CompletionResult]::new('get', 'get', [CompletionResultType]::ParameterValue, 'Get a setting value') | ||
| 159 | [CompletionResult]::new('set', 'set', [CompletionResultType]::ParameterValue, 'Set a setting value') | ||
| 160 | [CompletionResult]::new('list', 'list', [CompletionResultType]::ParameterValue, 'List all settings') | ||
| 161 | [CompletionResult]::new('unset', 'unset', [CompletionResultType]::ParameterValue, 'Unset a setting') | ||
| 162 | [CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)') | ||
| 163 | break | ||
| 164 | } | ||
| 165 | 'rsp;settings;help;get' { | ||
| 166 | break | ||
| 167 | } | ||
| 168 | 'rsp;settings;help;set' { | ||
| 169 | break | ||
| 170 | } | ||
| 171 | 'rsp;settings;help;list' { | ||
| 172 | break | ||
| 173 | } | ||
| 174 | 'rsp;settings;help;unset' { | ||
| 175 | break | ||
| 176 | } | ||
| 177 | 'rsp;settings;help;help' { | ||
| 178 | break | ||
| 179 | } | ||
| 180 | 'rsp;completions' { | ||
| 181 | [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') | ||
| 182 | [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') | ||
| 183 | break | ||
| 184 | } | ||
| 185 | 'rsp;help' { | ||
| 186 | [CompletionResult]::new('start-daemon', 'start-daemon', [CompletionResultType]::ParameterValue, 'Start the daemon') | ||
| 187 | [CompletionResult]::new('stop-daemon', 'stop-daemon', [CompletionResultType]::ParameterValue, 'Stop the daemon') | ||
| 188 | [CompletionResult]::new('restart', 'restart', [CompletionResultType]::ParameterValue, 'Restart the daemon (kill existing and start new)') | ||
| 189 | [CompletionResult]::new('play', 'play', [CompletionResultType]::ParameterValue, 'Play a track, album, or artist') | ||
| 190 | [CompletionResult]::new('pause', 'pause', [CompletionResultType]::ParameterValue, 'Pause playback') | ||
| 191 | [CompletionResult]::new('resume', 'resume', [CompletionResultType]::ParameterValue, 'Resume playback') | ||
| 192 | [CompletionResult]::new('toggle', 'toggle', [CompletionResultType]::ParameterValue, 'Toggle play/pause') | ||
| 193 | [CompletionResult]::new('stop', 'stop', [CompletionResultType]::ParameterValue, 'Stop playback') | ||
| 194 | [CompletionResult]::new('next', 'next', [CompletionResultType]::ParameterValue, 'Skip to next track') | ||
| 195 | [CompletionResult]::new('previous', 'previous', [CompletionResultType]::ParameterValue, 'Skip to previous track') | ||
| 196 | [CompletionResult]::new('volume', 'volume', [CompletionResultType]::ParameterValue, 'Set volume (0-100)') | ||
| 197 | [CompletionResult]::new('shuffle', 'shuffle', [CompletionResultType]::ParameterValue, 'Shuffle mode') | ||
| 198 | [CompletionResult]::new('queue', 'queue', [CompletionResultType]::ParameterValue, 'Queue management') | ||
| 199 | [CompletionResult]::new('status', 'status', [CompletionResultType]::ParameterValue, 'Show player status') | ||
| 200 | [CompletionResult]::new('scan', 'scan', [CompletionResultType]::ParameterValue, 'Scan music paths to populate database') | ||
| 201 | [CompletionResult]::new('settings', 'settings', [CompletionResultType]::ParameterValue, 'Settings management') | ||
| 202 | [CompletionResult]::new('completions', 'completions', [CompletionResultType]::ParameterValue, 'Generate shell completions (developer only)') | ||
| 203 | [CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)') | ||
| 204 | break | ||
| 205 | } | ||
| 206 | 'rsp;help;start-daemon' { | ||
| 207 | break | ||
| 208 | } | ||
| 209 | 'rsp;help;stop-daemon' { | ||
| 210 | break | ||
| 211 | } | ||
| 212 | 'rsp;help;restart' { | ||
| 213 | break | ||
| 214 | } | ||
| 215 | 'rsp;help;play' { | ||
| 216 | break | ||
| 217 | } | ||
| 218 | 'rsp;help;pause' { | ||
| 219 | break | ||
| 220 | } | ||
| 221 | 'rsp;help;resume' { | ||
| 222 | break | ||
| 223 | } | ||
| 224 | 'rsp;help;toggle' { | ||
| 225 | break | ||
| 226 | } | ||
| 227 | 'rsp;help;stop' { | ||
| 228 | break | ||
| 229 | } | ||
| 230 | 'rsp;help;next' { | ||
| 231 | break | ||
| 232 | } | ||
| 233 | 'rsp;help;previous' { | ||
| 234 | break | ||
| 235 | } | ||
| 236 | 'rsp;help;volume' { | ||
| 237 | break | ||
| 238 | } | ||
| 239 | 'rsp;help;shuffle' { | ||
| 240 | break | ||
| 241 | } | ||
| 242 | 'rsp;help;queue' { | ||
| 243 | break | ||
| 244 | } | ||
| 245 | 'rsp;help;status' { | ||
| 246 | break | ||
| 247 | } | ||
| 248 | 'rsp;help;scan' { | ||
| 249 | break | ||
| 250 | } | ||
| 251 | 'rsp;help;settings' { | ||
| 252 | [CompletionResult]::new('get', 'get', [CompletionResultType]::ParameterValue, 'Get a setting value') | ||
| 253 | [CompletionResult]::new('set', 'set', [CompletionResultType]::ParameterValue, 'Set a setting value') | ||
| 254 | [CompletionResult]::new('list', 'list', [CompletionResultType]::ParameterValue, 'List all settings') | ||
| 255 | [CompletionResult]::new('unset', 'unset', [CompletionResultType]::ParameterValue, 'Unset a setting') | ||
| 256 | break | ||
| 257 | } | ||
| 258 | 'rsp;help;settings;get' { | ||
| 259 | break | ||
| 260 | } | ||
| 261 | 'rsp;help;settings;set' { | ||
| 262 | break | ||
| 263 | } | ||
| 264 | 'rsp;help;settings;list' { | ||
| 265 | break | ||
| 266 | } | ||
| 267 | 'rsp;help;settings;unset' { | ||
| 268 | break | ||
| 269 | } | ||
| 270 | 'rsp;help;completions' { | ||
| 271 | break | ||
| 272 | } | ||
| 273 | 'rsp;help;help' { | ||
| 274 | break | ||
| 275 | } | ||
| 276 | }) | ||
| 277 | |||
| 278 | $completions.Where{ $_.CompletionText -like "$wordToComplete*" } | | ||
| 279 | Sort-Object -Property ListItemText | ||
| 280 | } | ||
