This chapter took us through the basics of creating a console application using the Spectre.Console.Cli library. This library removes a lot of the boilerplate code needed to parse command-line arguments and map them to operations in our code. By adopting their
Command pattern, we are able to focus on our code and functionality without having to worry much about the routing details.
In these lessons, we learned how to:
- create basic commands with optional parameters.
- make a default command for a console app.
- create nested commands that can split logical operations.
- create commands that have required parameters.
- configure commands to be discoverable by the
- integrate a dependency injection engine into the
ConsoleAppto build systems that are more robust and loosely coupled.
- build unit tests that validate the Commands in isolation.
- use mock objects to insulate tests from their dependencies, so that we can focus on testing the command logic.
- build integration/end-to-end tests that validate the console application from the user’s perspective.
These lessons were general purpose and should translate to most of the console applications that you may be interested in building. So I hope you make great use of them.
For future lessons, I am taking suggestions on what people would like to read more about. I could build a more complex console application to show how these concepts expand to broader usage. Or we could delve into the console UI framework of the Spectre.Console library to build pretty console applications. Or whatever intriguing suggestions that you may have. Feel free to leave me a message with your thoughts.