Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 1.42 KB

README.md

File metadata and controls

46 lines (35 loc) · 1.42 KB

Spectre.Cli

An extremly opinionated command line parser targeting .NET Standard 2.0.

NuGet Build Status

Usage

Below is a short example of how to configure the command chain. By using some clever generic constraints, the framework guarantees that all settings associated with a command is inherited from the parent commands' settings.

using Spectre.Cli;

public class Program
{
    public static int Main(string[] args)
    {
        var app = new CommandApp();

        app.Configure(config =>
        {
            config.AddBranch<EfSettings>("ef", ef =>
            {
                ef.SetDescription("Fake EF Core .NET Command Line Tools");
                ef.AddBranch<EfDatabaseSettings>("database", database =>
                {
                    database.AddCommand<EfUpdateCommand>("update");
                    database.AddCommand<EfDropCommand>("drop");
                });
            });
        });

        return app.Run(args);
    }
}

You can now execute the drop command like this:

./fakedotnet.exe ef --verbose database --no-color drop --startup-project "./../Foo/Foo.csproj" --dry-run

See the samples directory for more information.