Lessons – Command-Line Interface

Over the last few years, the command-line interface (CLI) has made quite a resurgence… harkening back to the day of command prompts and running in DOS. But today the CLIs are powerful tools to build our software and control integrations with our favorite cloud providers. And there are been great advances in frameworks for building rich, beautiful command-line apps that run on any platform.

The source code for these lessons can be found in the following repository: https://dev.azure.com/d20Tek/Tutorials/_git/command-line-tutorial


Chapter 1: Getting Started

This chapter looks at the core concepts of building command line interfaces with the Spectre.Console package. We will review the core concepts while building to a working sample.

Lesson 1.1: Starting with Spectre.Console.Cli
Introductory information about command-line interface frameworks and Spectre.Console.Cli in particular. Along with the HelloWorld for this CLI app.

Lesson 1.2: Multiple, Default, and Hidden Commands
Learn to build more complex command-line apps with multiple commands for control flow, default commands, and how to configure public and private commands.

Lesson 1.3: Nested Commands
Learn to build nested commands to enable command/sub-commands structures, and learn about defining required arguments.

Lesson 1.4: Async Commands
Learn to create and configure asynchronous commands and change the Main method to also be async.

Lesson 1.5: Setting Up Dependency Injection Components
Build integration components to use Microsoft.Extensions.DependencyInjection with Spectre.Console app.

Lesson 1.6: Using Dependency Injection
Use dependency injection integration with fully-functional repository and commands. See how you would use it in your own app.

Lesson 1.7: Setting Up Unit Test Project
Learn some basic concepts about unit testing and mock objects. Create an xUnit test project to test our commands from lesson 1.6.

Lesson 1.8: First Command Unit Test
Detailed description of our first command unit test focused on using the basics of xUnit and Moq to setup the test, execute it, and validate the expected results.

Lesson 1.9: Unit Testing Commands
Create the remaining set of unit tests for our student commands.

Lesson 1.10: CLI End to End Tests
Create the remaining set of unit tests for our student commands.

Lesson 1.11: The Wrap
Wrap up for Chapter 1 and review of learned concepts.


Please provide any feedback you have about the tutorial and individual lessons.