39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using Automancer.Common;
|
|
using Spectre.Console;
|
|
using Spectre.Console.Cli;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
namespace Automancer.Commands;
|
|
|
|
public class RootCommand : Spectre.Console.Cli.Command
|
|
{
|
|
private readonly CommandRegistry _registry;
|
|
|
|
public RootCommand(CommandRegistry registry)
|
|
{
|
|
_registry = registry;
|
|
}
|
|
public override int Execute([NotNull] CommandContext context)
|
|
{
|
|
AnsiConsole.Write(
|
|
new FigletText("AUTOMANCER")
|
|
.Centered()
|
|
.Color(Color.Cyan1));
|
|
|
|
AnsiConsole.MarkupLine("[bold]Automancer[/] is a modular CLI automation tool. It is designed to be extensible and easy to use.");
|
|
AnsiConsole.MarkupLine("Use [green]--help[/] or [green]<command> --help[/] to get started.");
|
|
|
|
var table = new Table().Border(TableBorder.Rounded);
|
|
table.AddColumn("[bold yellow]Module[/]");
|
|
table.AddColumn("[bold yellow]Description[/]");
|
|
|
|
foreach (var cmd in _registry.Commands.OrderBy(c => c.Path))
|
|
{
|
|
table.AddRow($"[green]{cmd.Path}[/]", cmd.Description ?? "[dim]n/a[/]");
|
|
}
|
|
|
|
AnsiConsole.Write(table);
|
|
return 0;
|
|
}
|
|
}
|