From console to CLI – parsing the arguments using an existing library
Although many libraries exist for the different programming languages, including .NET, we will focus on System.CommandLine
throughout this book.
You may be wondering why we chose this library, especially if you are familiar with (or have heard about) CommandLineParser
, which is another common library for that matter.
There are multiple reasons for that. In essence, System.CommandLine
is a more modern, feature-rich, and performant library, whereas CommandLineParser
is a simpler and more lightweight alternative.
Additionally, there are a few other reasons why I prefer System.CommandLine
:
System.CommandLine
is a .NET Foundation project developed by Microsoft and the community, whileCommandLineParser
is a third-party librarySystem.CommandLine
uses a builder pattern and a more declarative approach to define commands and options, whileCommandLineParser
uses attributes and a more imperative...