Open Bru456 opened 2 months ago
I agree that the current form of the System.CommandLine library requires a significant amount of code to get started.
Many CLI frameworks, including the one suggested, require a separate class implementation for each command. In my opinion, creating per-command classes adds unnecessary bloat to the code with little to no benefit. Attributes are still needed for additional information, such as descriptions and aliases.
My attempt to solve this problem resulted in the creation of the SnapCLI library, which is built on top of System.CommandLine and offers a simplified CLI API. This solution eliminates the need for separate classes by using only attributes (just 4 of them) and static methods as command handlers, aiming to streamline usage as much as possible. For more information, see the documentation and samples. I hope you find it useful.
I am relatively new to this library but I really like it.
It is somewhat complicated and difficult to get started on and requires a lot of code to get something up and running.
I would love to see the ability to add commands and options via attributes.
For example:
This could then be used in
Program.cs
to configure the CLIThis to me would allow for easy config, separation and testing of commands. Not to mention a cleaner looking
Program.cs
To summarise:
Additional future improvements if this is taken forward:
This would allow for cool things to be done such as common options (quiet, verbose, outpath, etc.) to be declared in a
BaseOptions
class and inherited into command classes.