ebb-earl-co / tidal-wave

Waving at the TIDAL music service
Apache License 2.0
38 stars 2 forks source link

Argument Completion in Powershell #78

Closed eevan78 closed 7 months ago

eevan78 commented 7 months ago

Hi, i tried to setup the completion in PowerShell 7.4.1, but I didn't manage to make it work. I'm using the tidal-wave_py311_pyapp.exe, I don't have Python installed on my system. As it is, the code cannot work, of course, as the command called in scriptblock to extract the information is python -m tidal-wave. I suppose that the environment variables there are just for debugging purpose. But there is a typo in one of them, as it has two spaces in it's name: $Env:_PYTHON _M TIDAL_WAVE_COMPLETE. Is it possible to have this working with tidal-wave_py311_pyapp.exe, or it has to be used only on systems with installed Python?

ebb-earl-co commented 7 months ago

Hi, @eevan78, thanks for having made an issue.

eevan78 commented 7 months ago

Hi @ebb-earl-co , I'm using the latest version of EXE, Release 2024.2.1. Here is the output of the commands:

PS D:\Software\Tidal-dl> .\tidal-wave_py311_pyapp.exe --show-completion pwsh
Import-Module PSReadLine
Set-PSReadLineKeyHandler -Chord Tab -Function MenuComplete
$scriptblock = {
    param($wordToComplete, $commandAst, $cursorPosition)
    $Env:_PYTHON _M TIDAL_WAVE_COMPLETE = "complete_powershell"
    $Env:_TYPER_COMPLETE_ARGS = $commandAst.ToString()
    $Env:_TYPER_COMPLETE_WORD_TO_COMPLETE = $wordToComplete
    python -m tidal_wave | ForEach-Object {
        $commandArray = $_ -Split ":::"
        $command = $commandArray[0]
        $helpString = $commandArray[1]
        [System.Management.Automation.CompletionResult]::new(
            $command, $command, 'ParameterValue', $helpString)
    }
    $Env:_PYTHON _M TIDAL_WAVE_COMPLETE = ""
    $Env:_TYPER_COMPLETE_ARGS = ""
    $Env:_TYPER_COMPLETE_WORD_TO_COMPLETE = ""
}
Register-ArgumentCompleter -Native -CommandName python -m tidal_wave -ScriptBlock $scriptblock
PS D:\Software\Tidal-dl> .\tidal-wave_py311_pyapp.exe --install-completion pwsh
Shells.pwsh completion installed in C:\Users\xxxxx\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
Completion will take effect once you restart the terminal
PS D:\Software\Tidal-dl>

Upon restarting the shell, I get the following:

PowerShell 7.4.1
ParserError: C:\Users\xxxxx\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:5
Line |
   5 |      $Env:_PYTHON _M TIDAL_WAVE_COMPLETE = "complete_powershell"
     |                   ~~
     | Unexpected token '_M' in expression or statement.
PS C:\Windows\System32>

$Env:_PYTHON _M TIDAL_WAVE_COMPLETE is the environment variable I was refering to in issue description, and there are two more, shown in the output of the first command.

Thanks for your assistance!

ebb-earl-co commented 7 months ago

@eevan78 I don't know if --show-completion is a typical Powershell feature, or if it's expected from tidal-wave itself: what I do know is that I had not seen this before you raised this issue!

I know that the Python library I use to handle the CLI arguments and running the main logic, typer has something to say about CLI option autocompletion in its documentation, but I have not looked into it, nor have I considered it as part of tidal-wave's core features.

If you can respond with a bit more information about this --show-completion flag, then maybe we can figure out what's going on here, but I can't promise any more assistance as this is outside what I know how to support in terms of tidal-wave's use on Windows.

P.S. does the executable work to retrieve audio and/or video as you would like? That, to me, is the most important question.

eevan78 commented 7 months ago

@ebb-earl-co I didn't know that this is a part of the library... Thanks for help, I will figure out how to make it work if it's possible. Executable works as a charm, no problems at all. So please don't waste your time on this, I'll close the issue!