CoreCmd is a MVC-like convention based command line automatic parser.
-
Build a command line project
-
Install CoreCmd NuGet package:
dotnet add package CoreCmd
-
Implement the entry
Main
method in theProgram.cs
file:using CoreCmd.CommandExecution; using System; namespace MyFancyCmd { // the 1st level subcommand: hello class HelloCommand { // the 2nd level subcommand: ben public void Ben() { Console.WriteLine("Ben() is called"); } } // the 1st level subcommand: good-morning class GoodMorningCommand { // the 2nd level subcommand: harry-potter public void HarryPotter(string param1, int param2) { Console.WriteLine($"HarryPotter() is called, param1={param1}, param2={param2}"); } } class Program { static void Main(string[] args) { // the only implementation for command parsing new AssemblyCommandExecutor().Execute(args); } } }
-
Execute:
c:\project\output\dir> dotnet myfancycmd.dll hello ben Ben() is called c:\project\output\dir> dotnet myfancycmd.dll good-morning harry-potter abcd 1234 HarryPotter() is called, param1=abcd, param2=1234