Giter Site home page Giter Site logo

dotnetcore.cmdargparser's Introduction

DotNetCore.CmdArgParser

Very easy to use and feature rich command line argument parser.

Installation

Using nuget: Install-Package PeterKottas.DotNetCore.CmdArgParser

Usage

  1. Using statement:
using PeterKottas.DotNetCore.CmdArgParser;
  1. Api for parsing:
CmdArgParser.Parse(config =>{
});
  1. Add your first parsing parameter
CmdArgParser.Parse(config =>{
  config.AddParameter(new CmdArgParam()
    {
      Key = "1stParamKey",
      Description = "This description is used for help",
      Value = val =>
      {
        innerConfig.Username = val; //What happens when we find this key, callback with injected value
      }
  });
});
  1. Advanced example
CmdArgParser.Parse(config =>{
  config.AddParameter(new CmdArgParam()
    {
      Key = "1stParamKey",
      Description = "This description is used for help",
      Value = val =>
      {
        switch(val){
          case "a":
            break;
          case "b":
            break
          default:
            Console.WriteLine("Only \"a\" and \"b\" are allowed values for key \"1stParamKey\". {0} was provided instead." val);
            break;
        }
      }
  });
});
  1. Parser api
CmdArgParser.Parse(config =>{
  config.UseDefaultHelp();//Configures a "help" parameter which displays default help
  config.UseAppDescription();//Configures app description used in help
  config.ShowHelpOnExtraArguments();//Show's extra arguments
  config.CustomHelp(helpData=>
  {
  });//Configures custom help. You can provide a function that displays custom help for you application. You get the array of parameters provided to you via parameter HelpData
  config.DisplayHelp();//Displays help. Useful inside parameter callbacks.
});

Created and sponsored by

  • GuestBell - Customer centric online POS for Hotels and short terms stays.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

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.