#
🎨 ChrissyColors Powershell Binary Module
#
Powershell Binary Adventures 🤓
So this is quite an epic adventure of a tale featuring Powershell Modules. As I mentioned before I am really happy with some of the people who have accepted my follow request by not blocking me, and sometimes even followed me back on Twitter. One of these amazing people is Chrissy Lemaire. As you probably know Chrissy is an MVP, as well as a GitHub Star and even an author! Damn how many things can one person be? Then on-top of all this I can vouch Chrissy is a really amazing person especially when it comes to showing others some of the super cool things you might not know even exist.
Chrissy tweeted about trying to build something to return hex color codes not to sure if Chrissy is redecorating her home, but I felt I could actually lend a helping hand in this task. Although I didn't know what the actual task fully involved, it just did not seem like rocket science, so I offered my help.
To my astonishment Chrissy said that would be a good idea, so I got chatting to Chrissy to find out exactly what the task at hand was. See for me personally the Powershell Gallery used to be my single pit-stop of the go-to, to get something for Powershell. These days I like to look at several other places for something that might already exists to do the job. I do not want to come across as a charlatan but if something already exists why re-invent the wheel?
As I love to make command-line tools into Crescendo modules I figured scoop would be a good place to check if something out there existed already for this task at hand.
So I searched for color I know this is not the correct English spelling but for those that have plagiarised the queens speech this is the standard spelling for colour. As I know Chrissy is a fellow geek, I figured I should really try and find a command line tool. Someone was looking down on me, as I found a command-line program called Pastel all I had to do to install this (as I already have scoop installed) was use
scoop install pastel
Boom, the program was installed, so I read the help file and the github repository to see what I could do with this command line program that appeared to tick all the boxes of the given problem
Now the only thing I had beef with was this program only appeared to return string data which meant that this particular program was a bad candidate to try and make into a Crescendo module, as it would not be able to be converted to a true Powershell objects, and would just be string data. The parameter-set for this application was not difficult for me to understand, so again I could not justify putting this into a Crescendo module because it was easy enough to use as it was, and did not offer outputting in any other formats like JSON or CSV so I would not be able to turn this into Powershell objects. However I did notice from the github page that this allowed pipelines in the program, so I figured I could do this
💥 Boom Chrissy came back to me to say this did indeed tick the boxes for the problem. So I was so happy I had helped out in some-way in providing a solution to the problem by finding this command-line colour program. But it was bugging me a bit that I could not see the need to turn this into a Crescendo module due to the reasons already mentioned, so this was not a Powershell solution. I got a lot of respect for Chrissy for who she as and the things she has achieved, and how much of a fountain of knowledge Chrissy is for the community and to always share that knowledge back to the community, it is phenomenal hence I got so much respect for Chrissy.
I got chatting with Chrissy again later in the evening to see how using Pastel was going on her personal colour quest. It seemed Chrissy was struggling to find that perfect colour. So I grabbed my mask and cape, and flew over to nuget.org to find a C-sharp library I could use to generate colours.
Again I was blessed. To my delight I had found the following library
This appeared that it could generate me a load of different colours, and being C-sharp I knew it would be super-quick. Like I know there are various colour generators out there to generate colour schemes mainly web-based, but normally the API for these sites is a paid-for service.
In My Opinion
The best things in life are free
Again as always I wanted to give an automated solution to Chrissy in her quest to find that perfect colour. If all this could be done automatically from the shell, then to me that would be well worth turning this into a Powershell Binary Module
I even made a small Github repository to host all the code I did on how I made this into a binary module. I do plan on adding to this repository and all my other respositories, GitHub actions to implement a CI/CD process to automate the testing of my modules. Anyways you can find the ChrissyColors repository here
Yes I know currently the readme for this totally rubbish, but I have written this exclusive blog in the mean-time. As mentioned in the previous paragraph, I got big plans to do more things on GitHub in general.
Finally after testing the ChrissyColors.dll I had built and published, I then had the task of creating the actual .PSD1 Powershell module file. New-ModuleManifest
is the cmdlet I use to accomplish this task, and I personally fill in as many of the parameters as possible. Once this was done I uploaded this to the Powershell Gallery as to my knowledge no colour generators exist on there. Else I am sure Chrissy would not have needed my help.
💥 Boom I had now delivered a Powershell solution to the problem even though the original problem was solved, it now seemed a new problem of finding the perfect colour. So instead of manually spending time to find the perfect colour, you can use this module instead. Using Pastel as well with this module allows you to physically see all the colours generated. As you can see in the gif above, without Pastel just the hex codes are shown for the colours, as shown at the start of the gif when I just generate loads, and loads of colour codes in no-time at all. The main time was scrolling through looking at all the beautiful colours that had been automatically generated. The amount of colours returned is controlled by the only parameter -NumberOfResults
the higher the integer value, the more colours returned. In the gif example I used 34 as the number of results to return.
#
Super Dope Project ☺️
Damn, I do love doing this sort of thing, like helping people. It was only a few days ago my lovely wife spotted an old lady struggling to even lift her shopping, I then helped this old-dear by carrying all her shopping back to her car for her, and loading it into the vehicle. Helping people does give me a buzz, being able to lend a helping hand to Chrissy was almost an overdose-buzz, I was buzzing so much that I had chipped in on the colour dilemma Chrissy was suffering. I also found out about 2 other cool things, Pastel, and the binary module I made. I got an enormous amount of respect for Chrissy and I am super thankful for the help she has given. So was nice to be able to repay a small amount of the kindness Chrissy has shared, back to Chrissy. The End.
Thanks for reading the origins of ChrissyColors and how you can use this, and also where you can get it from. Till next time stay safe.