ExtendedConsole
ExtendedConsole was created after writing many .Net console applications,
and finding myself spending way too much time and effort on doing what should be - in my humble opinion - simple and trivial tasks.
Things like highlighting parts of the output text, validating and parsing user inputs, and creating simple menus.
All of these tasks seems to have been, for the lack of a better term, neglected when it comes to console applications.
ExtendedConsole is here to provide easy-to-use solutions to these tasks,
and the best thing about it is that you can easily add whatever features you want to it, simply by writing extension methods.
ExtendedConsole is completely open source and free to use, under the MIT licence.
It's source code is available on GitHub, and it's also available as a Nuget package.
ExtendedConsole provides the following features:
-
Markup support:
ExtendedConsole provides a super simple, xml based markup support for writing text to the Console.
No more breaking up your strings to multiple Console.Write commands just to color parts of your text - With ExtendedConsole it's as easy as
exConsole.Write("The following text is <c b='darkRed' f='white'>White on a dark red background</c>");
-
Menus:
ExtendedConsole provides methods to generate console menus.
Creating a menu with ExtendedConsole is just simple method call:
var selected = exConsole.Menu( new MenuDisplayArgs("What to do next?"), ("
Quit ", null), ("Go here", GoHere), ("Pause", () => exConsole.Pause()), ("Do that", DoThat) ); -
User inputs:
ExtendedConsole provides methods to help you read and parse user input.
It supports int, boolean, DateTime, and custom classes and structs.
For instance, to get a number between 0 and 5 from your users, use this:
var result = exConsole.ReadInt( "Please enter an int between
0 and5 , inclusive.", i => i >= 0 && i <= 5 ); -
Clear lines:
ExtendedConsole provides methods to clear a specific line or lines.
For instance, to clear the last three lines of the console, use this:
exConsole.ClearLastLines(3);
Easily extensible
ExtendedConsole is designed to be as easy to extend as possible.
All you have to do is add whatever extension methods you need.
This is one of the main reasons it's built as a single main class,
and most of it's features are in extension methods - it provides two clear benefits:
- It can be used as a guideline to users on how to add features.
- It makes it easier to maintain, as the classes are relatively small and focused.