Skip to content

lifewithcoffee/CoreCmd

Repository files navigation

About CoreCmd

CoreCmd is a MVC-like convention based command line automatic parser.

Quick Start

  1. Build a command line project

  2. Install CoreCmd NuGet package:

    dotnet add package CoreCmd

  3. Implement the entry Main method in the Program.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);
            }
        }
    }
  4. 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

About

A convention based command line automatic parser

Resources

License

Stars

Watchers

Forks

Packages

No packages published