mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00

* Adding a dark mode * Adding reference for types to summary pages * Adding API Reference * Adding modifiers to methods/fields/etc * Minimizing files input * Caching a lot of the output pages * Cache only for each execution * Adding API references to existing docs
39 lines
840 B
C#
39 lines
840 B
C#
using Spectre.Console;
|
|
using Spectre.Console.Cli;
|
|
|
|
namespace Delegates;
|
|
|
|
public static partial class Program
|
|
{
|
|
public static int Main(string[] args)
|
|
{
|
|
var app = new CommandApp();
|
|
app.Configure(config =>
|
|
{
|
|
config.AddDelegate("foo", Foo)
|
|
.WithDescription("Foos the bars");
|
|
|
|
config.AddDelegate<BarSettings>("bar", Bar)
|
|
.WithDescription("Bars the foos"); ;
|
|
});
|
|
|
|
return app.Run(args);
|
|
}
|
|
|
|
private static int Foo(CommandContext context)
|
|
{
|
|
AnsiConsole.WriteLine("Foo");
|
|
return 0;
|
|
}
|
|
|
|
private static int Bar(CommandContext context, BarSettings settings)
|
|
{
|
|
for (var index = 0; index < settings.Count; index++)
|
|
{
|
|
AnsiConsole.WriteLine("Bar");
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|