PoshCode / Pansies

Powershell ANSI Escape Sequences, functions for colored output, etc.
MIT License
148 stars 14 forks source link

Initializing Write-Host fails? #27

Closed LukasMarsch closed 1 year ago

LukasMarsch commented 1 year ago

When i load up a new Console and try to

Write-Host ">" -ForegroundColor "#222222" -BackgroundColor Gold

I get an Error

Write-Host: Cannot bind parameter 'BackgroundColor'. Cannot convert value "Gold" to type "System.ConsoleColor". Error: "Unable to match the identifier name Gold to a valid enumerator name. Specify one of the following enumerator names and try again:
Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White"

This is from the Legacy Write-Host command. Once i call for example

Get-ColorWheel

I can run my first Write-Host command as expected

Terminal: Alacritty

Example: image

kilasuit commented 1 year ago

Once you run Get-ColorWheel, Pansies will load and this replaces the default Write-Host with it's implementation If you want this all the time, then load Pansies in your Profile then all calls to write-host will use the Pansies version in that session

Hope that helps @LukasMarsch!

Jaykul commented 1 year ago

You can call PANSIES\Write-Host explicitly -- otherwise, it only clobbers the built-in Write-Host when you have Pansies imported.

You can import it in your profile, locally, that takes care of everything.

In scripts, you should #requires -module Pansies

In modules, you should add it to your module manifest in RequiredModules = @('Pansies')