jacobdeichert / mask

🎭 A CLI task runner defined by a simple markdown file
MIT License
1.11k stars 55 forks source link

Arguments don't work in Powershell #81

Closed berwyn closed 3 years ago

berwyn commented 3 years ago

I'm using Mask on Windows 10 and have a task in my maskfile.md that accepts an argument, however this seems to be empty when tested in the script. I've tested both the legacy Powershell that ships with the system (some flavour of 5.1) and the current preview release of the modern Powershell and in both cases Powershell will just output an empty line.

OS: Windows 10 21313.1000 Shell: Powershell 5.1.21313.100, Powershell 7.2.0-preview.3

# Powershell example
## powershell legacy (value)
> 5.1.21313.100
~~~powershell
Get-Host | Select-Object Version
Write-Output "${value}"
~~~

## powershell modern (value)
> 7.2.0-preview.3
~~~pwsh
Get-Host | Select-Object Version
Write-Output "${value}"
~~~
jacobdeichert commented 3 years ago

Hmmm, I don't know too much about powershell, but I think you might need to access env variables like this?

param (
    $value = $env: value
)

I'm not 100% certain though. I just grabbed this from our maskfile.md which includes powershell blocks for Windows:

Screen Shot 2021-03-05 at 10 02 25 AM

If this works, let me know and I can probably improve the README documentation with an example!

berwyn commented 3 years ago

Aha, right! It totally went over my head that they're environment variables and that they need to be addressed as such! For some reason, I was thinking they were being passed as params. Thanks for the clarification, and sorry to distract you with a misunderstanding on my part!