Git Product home page Git Product logo

command-core's Introduction

Build Project Coverage Status NuGet version (CommandCore.Library) GitHub

A simple command line parsing library that helps creating CLI apps using MVC pattern.

There are many command line parsing libraries out there, but most of them are unnecessarily complicated. Command Core library is built using a well-understood desing pattern: MVC. It cleanly separates the building blocks and makes the CLI development a scalable, extensible, and more importantly simpler endeavor.

Check out WIKI to get started!

Check out the WIKI page to learn more on how to get started with CommandCore!

Release Changelog

Check out this page to see what's changed with every new release: https://github.com/tarikguney/command-core/wiki/Changelog

Quick Look

If you are familar with MVC pattern in any framework, you will find CommandCore very familiar with them. Look at below to see how a simple command like the one below can be represented in your .NET application:

helloworld.exe add --firstname tarik --lastname guney --haslicense -a 33 --id 1 2 3
[VerbName("add", Description="Allows to add a new person to the database.")]
[VerbName("add-person")]
public class Add : VerbBase<AddOptions>
{
    public VerbView Run(){
        return AddView(Options);
    }
}

public class AddView : VerbViewBase<AddOptions>
{
    public override void RenderResponse(){
        Console.WriteLine(
             $"FirstName: {_options!.FirstName}\n" +
             $"Last Name: {_options!.LastName}\n" +
             $"Has License: {_options!.HasLicense}\n" +
             $"Age: {_options.Age}\n" +
             $"Ids: {_options.Ids.Select(a => a.ToString()).Aggregate((a, b) => a + "," + b)}");
    }
}

public class AddOptions : VerbOptionsBase
{
    [OptionName("firstname")]
    [OptionName("fn"), Alias="f")]
    public string FirstName {get;set;}
    
    [OptionName("lastname")]
    public string LastName {get;set;}

    [OptionName("haslicense")]
    public bool? HasLicense {get;set;}
    
    [OptionName("age", Alias="a")]
    public int Age {get;set;}

    [OptionName("id")]
    public List<int> Ids { get; set; }

}

Integrated IoC Container for Dependency Injection

CommandCore comes with an in-house IoC container named CommandCore.LightIoC, and it allows you to register your own services and inject them to the verb classes. Check out this page for more information: Dependency Injection with LightIoC Container

Roadmap

  1. Add routing mechanism, similar to Asp.NET Core MVC. Routing mechanism will help verbs to be routed to a desired class pattern for more complicated scenarios.
  2. Add a middleware, which is similar to Asp.NET Core MVC request/response middleware features, which allows the developers to inject logic between a command is routed to its handling verb (controller).
  3. Caching for faster type lookup. Currently, the entire assembly needs to be scanned for the types that match the verb. A caching mechanism can store away the detected types for faster retrival next time.

Developed

by Tarik Guney with .NET Core 3.x.

command-core's People

Contributors

tarikguney avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.