I needed to write a console application a while back and was investigating the best way to do this using the available NuGet packages. I’d seen the DNVM command line tool that Microsoft built for ASP.NET Core and really liked it and wanted something similar.
I really like the old school ASCII art title and the use of colour. The .NET Framework does contain an enum called ConsoleColor which contains a very limited set of hard coded colours you can use but it has some major ommissions like the colour orange for example.
In my hunt for a C# ASCII art generator, I discovered patorjk.com which is great for generating text using various Figlet fonts. Figlet fonts are basically .flf text files which contain instructions on how each letter in the ASCII character table can be printed out. It turns out these font’s are pretty ancient and there are libraries in every language writing out text using Figlet fonts.
I was just about to give up and write my own open source library when I discovered Colorful.Console, available on GitHub. Using this library you can very easily write console apps which look like this:
The only thing missing was a method to write ASCII text using Figlet fonts, so I contributed some code to the project to get this done. The output, combined with the fade that Colorful.Console is capable of created a pretty cool effect. Unbelievably this is a couple of lines of code to write!
The title image of this post is also generated using Colorful.Console but was a bit more complicated as it transitions through several colours. By default Colorful.Console includes a single Figlet font but there are dozens of others available which you can download and use yourself. They aren’t all included by default because they would bloat the library quite a bit.
Command Line Parsers
Now the only thing missing in my quest was a command line parser which could let me easily create commands, switches and flags so users could use my command line tool. The best tool I found was Command Line Parser available on GitHub. It’s a pretty powerful and fully features library that makes writing a command line interface very easy. Unfortunately, its output is pretty ugly and it does not let you customize the ‘look and feel’ of what is output to the console.
At some point, I’d like to make another contribution to Colorful.Console, so that it offers command line parsing too but take inspiration from several command line parsing libraries to make something thats fully customizable and of course very colorful.
Command line tools have been around for decades, it’s a wonder that a NuGet package that does all of these things does not exist yet.