CLI Rewrite with System.CommandLine #4220
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull uses the community & microsoft driven library System.CommandLine which is currently in v2-beta5.
When compared to Spectre.Console.Cli, this means no requirements for interfaces/classes and attributes to derive the CLI interface.
We miss out on aesthetics. But I am fine to be patient with this, as it's simply a matter of the library becoming polished enough to allow more hooks and customisation with the help message rendering.
We can still use Spectre.Console to render everything outside the help messages.
Completions?
Using
dotnet-suggest
, System.CommandLine supports completions for zsh, bash and powershell.Progress
After tinkering and testing some elements of the package, I've implemented a skeleton structure to show how the CLI interface could be logically reasoned and derived.
I have again implemented the CLI options as a interface hierarchy, as this simplifies consuming the args imo.
Nothing has actually been hooked in yet, as some validation has to be added (there should be architecture already existing that supports multiple validation error message reporting like I did with Spectre.Console.Cli).
It's important before this progresses to know whether this API for creating the CLI is acceptable.
Images
As a proof of concept and test, I used ANSI escape sequences to color what is readily available dim. All descriptions can be safely manipulated.