namespace spectbug { using Microsoft.Extensions.DependencyInjection; using spectbug.Commands; using Spectre.Console.Cli; public static class Program { public static void Main(string[] args) { var app = new CommandApp(BootstrapServices()); app.Configure(opts => { opts.SetApplicationName("spectbug"); opts.SetApplicationVersion("1.0"); //opts.ValidateExamples(); // => Spectre.Console.Cli.CommandConfigurationException: 'Validation of examples failed.' // Unknown option 'm' // but 'm' is defined at PrintBaseSettings:L8 opts.AddBranch("print", p => { p.SetDescription("Print message"); p.AddCommand("repeated") .WithAlias("repeat") .WithDescription("Print message several times") .WithExample(new[] { "print", "repeated", "-m", "Lorem ipsum", "-r", "5" }); p.AddCommand("decorated") .WithAlias("decor") .WithDescription("Print with foo flavor") .WithExample(new[] { "print", "decorated", "-m", "Lorem ipsum", "--with-foo" }); }); }); app.Run(args); } private static TypeRegistrar BootstrapServices() { var services = new ServiceCollection(); //services.AddSingleton(); // why needed? //services.AddSingleton(); // why needed? services.AddSingleton(); //services.AddSingleton(); // why needed? //services.AddSingleton(); // why needed? return new TypeRegistrar(services); } } }