Skip to content

Jandini/RightTurn.Extensions.CommandLine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RightTurn.Extensions.CommandLine

Provides CommandLine Parser extensions for RightTurn

Quick Start

Parse verbs
static void Main(string[] args) => new Turn()
    .ParseVerbs(args)
    .WithDirections()
    .Take((provider) =>
    {
        var directions = provider.GetRequiredService<ITurnDirections>();

        switch (directions.Get<ITurnArgs>().Options)
        {
            case IVerbOptions1 options:
                provider.GetRequiredService<IVerbOptions1>().Run(options);
                break;

            case IVerbOptions2 options:
                provider.GetRequiredService<IVerbOptions2>().Run(options);
                break;

            default:
                throw new NotImplementedException();
        };
    });
Customize parser
new Turn()
    .WithParser(new Parser((settings) => { settings.HelpWriter = null; }))
    .ParseVerbs(args, (result) =>
    {
        Console.WriteLine(HelpText.AutoBuild(result, h =>
        {
            h.Heading = title;
            h.AdditionalNewLineAfterOption = false;
            h.Copyright = string.Empty;
            h.AddDashesToOption = true;

            return HelpText.DefaultParsingErrorsHandler(result, h);
        }, e => e, true));
    })

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages