I've always been fascinated with the Amiga demo community and the Warez scene. I've especially loved cracktros
, small graphical demos that were played before a cracked game. Names like Razor 1911, Skid Row, Paradox, Crystal, and Red Sector would pop up on the screen, often with better graphics and music than in-game.
echo _---~~(~~-_.
echo _{ ) )
echo , ) -~~- ( ,-' )_
echo ( \`-,_..\'., )-- '_,)
echo ( \` _) ( -~( -_ \`, }
echo (_- _ ~_-~~~~\`, ,' )
echo \`~ -^( __;-,((())))
echo ~~~~ {_ -_(())
echo \`\\ }
echo { }
Unfortunately, I'm not doing anything so cool, like creating cracktros
in the enterprise software arena. Still, at least I can put some magic in the console applications with ASCII Splash Screens
. The tool that helps me reach these lofty goals of putting a tiny bit of personality in bland corporate applications is Spectre.Console
!
Spectre.Console
is a library that helps us create beautiful console applications in .NET.
dotnet add package Spectre.Console
It has many features, like tables, progress bars, JSON visualizer, selection, multi-selection, tree view, etc. Even if you don't have experience with console graphics, it's simple to use and much more straightforward than GUI development.
AnsiConsole.Status()
.Spinner(Spinner.Known.Star)
.SpinnerStyle(Style.Parse("blue"))
.Start("Translating with OpenAI...", ctx =>
{
var translationResults = translationService.Translate(
englishValue,
context,
LanguageData.List.Where(x => x != LanguageData.EnglishUK).ToList());
foreach (var translation in translationResults.Where(x => x.Key != LanguageData.SerbianLatinAlphabet))
{
machineTranslations.Add(translation.Key.ShortName, translation.Value);
ctx.Status($"Translated to {translation.Key.Name}");
}
// Display translations in a table
var table = new Table()
.AddColumn("Language")
.AddColumn("Translation")
.Border(TableBorder.Rounded);
foreach (var translation in machineTranslations)
{
table.AddRow(
$"[blue]{LanguageData.List.Single(x => x.ShortName == translation.Key).Name}[/]",
translation.Value);
}
AnsiConsole.Write(table);
});
Simple spinner and the table
Conclusions
I love command-line interfaces (CLI)
. They provide a simple but effective way to input and output information. Sure, they are limited compared to GUI, but with creative ways of using CLI, we can often create simple but usable visualizations, even in console apps, with little effort.
I use Spectre.Console
for every console application. It's a great way to make it more user-friendly and visually appealing. Spectre.Console's widgets are a great way to represent the data meaningfully in the CLI. The best thing is that you do not have to do that much. You can create your console app and then just 'order' ChatGPT
or Claude.Sonnet
to make it more visually appealing or to visualize some data with Spectre.Console
! It works great!