Lesson 1.11: The Wrap

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 ConsoleApp class.
  • integrate a dependency injection engine into the ConsoleApp to 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.

3 thoughts on “Lesson 1.11: The Wrap

  1. Hi! Great posts, I enjoyed.

    You asked about potential topics for followup posts. My thoughts:

    – Theming (color schemes)
    – my terminal has a custom color profile, how can I make my CLI app follow those colors? Do I need to do anything?
    – Auto complete (of commands, so that “myapp li” completes to “myapp list”)
    – Registering the command, so that I can globally type “myapp list” instead of “/path/to/binary/myapp.dll list”
    – Data binding? MVVM?
    – Handling of secrets, e.g. a user password to a remote service

    I’m also interested in some approach to a long running CLI UI, maybe something that refreshes + renders some remote dataset periodically?

    Keep rocking!


    1. Thanks for the feedback. The color and theming for CLI apps is really covered well by the Spectre.Console documentation and samples. I really recommend that you read those.

      I will take a look at some of those other suggestions. They certainly seem like good places to expand these topics.


      1. ๐Ÿ‘
        I did not get around to try out the Spectre libraries myself yet, but I have some ideas I want to look into (for a long time already) ๐Ÿ™‚
        Thank you for blogging


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s