ShaunLawrie / PwshSpectreConsole

👻 PwshSpectreConsole is a PowerShell wrapper for the awesome Spectre.Console library
https://pwshspectreconsole.com/
MIT License
117 stars 7 forks source link

Draft New Validate/Argumentcompletions #11

Closed trackd closed 1 year ago

trackd commented 1 year ago

Need to do some more tests, but figured i'd show you how i thought it could be solved.

this is a bit more concise.

aims to solve #9 & #10

I added a few where i found applicable,

Invoke-SpectreCommandWithStatus -ScriptBlock { Start-Sleep -Seconds 5 } -Spinner Christmas -Title "Waiting for process to complete" -Color yellow

^ fun ;)

Invoke-SpectreCommandWithStatus -ScriptBlock { Start-Sleep -Seconds 5 } -Spinner Christmas222 -Title "Waiting for process to complete" -Color yellow
# outputs
Invoke-SpectreCommandWithStatus: Cannot validate argument on parameter 'Spinner'. Value 'Christmas222' is invalid. Try one of: Default,Ascii,Dots,Dots2,Dots3,Dots4,Dots5,Dots6,Dots7,Dots8,Dots9,Dots10,Dots11,Dots12,Dots8Bit,Line,Line2,Pipe,SimpleDots,SimpleDotsScrolling,Star,Star2,Flip,Hamburger,GrowVertical,GrowHorizontal,Balloon,Balloon2,Noise,Bounce,BoxBounce,BoxBounce2,Triangle,Arc,Circle,SquareCorners,CircleQuarters,CircleHalves,Squish,Toggle,Toggle2,Toggle3,Toggle4,Toggle5,Toggle6,Toggle7,Toggle8,Toggle9,Toggle10,Toggle11,Toggle12,Toggle13,Arrow,Arrow2,Arrow3,BouncingBar,BouncingBall,Smiley,Monkey,Hearts,Clock,Earth,Material,Moon,Runner,Pong,Shark,Dqpb,Weather,Christmas,Grenade,Point,Layer,BetaWave,Aesthetic

looks a bit better in console with linewrap but.. errors can be a bit long sometimes.. might want to remove the ErrorMessage on a few, like colors?

    [ValidateSet([SpectreConsoleTableBorder],ErrorMessage="Value '{0}' is invalid. Try one of: {1}")]
ShaunLawrie commented 1 year ago

Nice! I didn't know about IValidateSetValuesGenerator, that's really what I was after the first time. I'm working on splitting up the big PwshSpectreConsole.ps1 file and rewriting the docs in https://github.com/ShaunLawrie/PwshSpectreConsole/tree/prerelease (copilot did most of the first cut and they're a it rough 😆)

I've updated that branch to use this approach

trackd commented 1 year ago

Sweet, should probably close this then :)