Closed futuremotiondev closed 6 months ago
Update: Modified the erroneous dot-source statement block:
using module ".\private\completions\Completers.psm1"
# Dotsource default configuration
Get-ChildItem -Path "$PSScriptRoot\private\defaults\*.ps1" -Recurse | ForEach-Object {
. $_.FullName
}
# Dotsource each function in Private and Public
foreach ($directory in @('private', 'public')) {
Get-ChildItem -Path "$PSScriptRoot\$directory\*.ps1" -Recurse | ForEach-Object {
. $_.FullName
}
}
using module ".\private\completions\Completers.psm1"
# Dotsource each function in Private and Public
foreach ($directory in @('private', 'public')) {
Get-ChildItem -Path "$PSScriptRoot\$directory\*.ps1" -Recurse | ForEach-Object {
. $_.FullName
}
}
I updated the PR to include this change. I have no idea what I was doing with that first dot-source block. The second one already imports Initialize-DefaultColors.ps1
Apologies for the bad code.
When I reimplemented the table colors from your PR I just left these where they were for now in the psm1. If we need theming it can be added in another change.
The table colors can be set with Set-SpectreColors and you could pass a splat to it as a theme at the moment.
https://pwshspectreconsole.com/reference/config/set-spectrecolors/
Really sorry for not being more active on this!
After taking some time away from coding I spent all day/night working on a C# helper library for the module. Right now it's specifically focused on extending the capabilities of formatting tables. You can pass it objects, lists containing objects, scalar arrays, whatever - and it will handle it all gracefully in the same manner that the module works now.
You can also add columns manually, specify the width of each column by percentage or direct values. You can specify colors for any component, etc.
There is also a ColorValue class that handles all conversions between SpectreConsole color names, HEX codes, and RGB ValueTuples.
Lastly I put together all the enums associated with the library. There is also a public facing dictionary that associates all colors with their hex values, RGB values, and names.
Here's some links:
https://github.com/fmotion1/PwshSpectreConsoleHelpers https://github.com/fmotion1/PwshSpectreConsoleHelpers/blob/main/SpectreTableHelpers.cs https://github.com/fmotion1/PwshSpectreConsoleHelpers/blob/main/SpectreColorValue.cs
Took forever to get it to build successfully but finally nailed it with no warnings / errors.
I still have to test it all - really tired after this marathon of coding. Let me know what you think.
Really sorry for not being more active on this!
Not a problem. You can do as little or as much as you want it's just a bit of fun. I appreciate all your inputs, I'm learning a lot on this project
I'll have to take a better look when I'm not so tired. I'm not sure at the moment what your use case is because there is so much at once 😄
For where you're using enums I'm using a different approach in the library to grab them at runtime:
[Spectre.Console.TableBorder] | Get-Member -Static -MemberType Properties | Select-Object -ExpandProperty Name
So they can be used as argument completers like this:
Really sorry for not being more active on this!
After taking some time away from coding I spent all day/night working on a C# helper library for the module. Right now it's specifically focused on extending the capabilities of formatting tables. You can pass it objects, lists containing objects, scalar arrays, whatever - and it will handle it all gracefully in the same manner that the module works now.
You can also add columns manually, specify the width of each column by percentage or direct values. You can specify colors for any component, etc.
There is also a ColorValue class that handles all conversions between SpectreConsole color names, HEX codes, and RGB ValueTuples.
Lastly I put together all the enums associated with the library. There is also a public facing dictionary that associates all colors with their hex values, RGB values, and names.
Here's some links:
https://github.com/fmotion1/PwshSpectreConsoleHelpers https://github.com/fmotion1/PwshSpectreConsoleHelpers/blob/main/SpectreTableHelpers.cs https://github.com/fmotion1/PwshSpectreConsoleHelpers/blob/main/SpectreColorValue.cs
Took forever to get it to build successfully but finally nailed it with no warnings / errors.
I still have to test it all - really tired after this marathon of coding. Let me know what you think.
Nice !
I'm still learning C# but I'm actually working on something very similar. https://github.com/trackd/PwshSpectreConsole.VT
I'm trying to convert the VT to Spectre color logic into pure C# cmdlet.
but it's overly complicated at the moment, i kinda feel like if i structure my objects differently i can make it easier but i havnt really figured out how.
theres too many steps from a VT string to a text
/ markup
object..
multi color strings is really where it gets dicey 😅 kinda tempted to say thats just not supported because of the complexity but i also kind of want to figure it out because its a fun problem.
I'd love some help figuring out the "cheapest" (performance wise) way to convert.
I looked over your code briefly but havnt had a chance to look in detail.
I do think the latest version (1.7) solves a few of the issues that (it looks like) your trying to fix in your C#?
I went a little bit of a different route than you, i load the Spectre library directly in my project so i can access all the methods and properties like colors it does make it a bit easier.
my code is a bit of a mess at the moment with some unused or just me testing things out, it's quite a volatile codebase 🤣 feel free to copy / use / pr
Link to PR#23
Overview
$script:AccentColor
and$script:DefaultValueColor
definitions from PwshSpectreConsole.psm1private
calleddefaults
, and moved the above definitions to a new file called Initialize-DefaultColors.ps1However looking at the code now, I think the first statement under
# Dotsource default configuration
is redundant as the below foreach loop already dot-sources everything inprivate
.So I'm going to change the
.psm1
to something like this:Initialize-DefaultColors.ps1
:Note:
$script:DefaultTableTextColor
does nothing right now.Future Plans
-TextColor
parameter toFormat-SpectreTable
.-TitleColor
parameter toFormat-SpectreTable
.-Color
inFormat-SpectreTable
to-TableBorderColor
-AllowMarkup
switch, we can also colorize the text of any cell in the table,Comments / Discussions / Critiques / Proposed Changes are welcome!