diff --git a/README.md b/README.md index 9aed153..c01ce99 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,37 @@ # Community.Extensions.Spectre.Cli.Hosting Extension methods and a bit of fancy footwork to host Spectre.Console.Cli in a HostApplicationBuilder + +``` + +var builder = Host.CreateApplicationBuilder(args); + +// Add a command and optionally configure it. +builder.Services.AddCommand("hello", cmd => +{ + cmd.WithDescription("A command that says hello"); +}); + + +// Add another command and its dependent service + +builder.Services.AddCommand("other"); +builder.Services.AddScoped(s => new SampleService("Other Service")); + +// +// The standard call save for the commands will be pre-added & configured +// +builder.UseSpectreConsole(config => +{ + // All commands above are passed to config.AddCommand() by this point + +#if DEBUG + config.PropagateExceptions(); + config.ValidateExamples(); +#endif + config.SetApplicationName("hello"); + config.UseBasicExceptionHandler(); +}); + +var app = builder.Build(); +await app.RunAsync(); +``` \ No newline at end of file