37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using Spectre.Console;
|
|
using System.Reflection;
|
|
namespace AnchorCli.Commands;
|
|
|
|
public class StatusCommand : ICommand
|
|
{
|
|
private readonly string _model;
|
|
private readonly string _endpoint;
|
|
|
|
public StatusCommand(string model, string endpoint)
|
|
{
|
|
_model = model;
|
|
_endpoint = endpoint;
|
|
}
|
|
|
|
public string Name => "status";
|
|
public string Description => "Show current settings (model, endpoint, working directory)";
|
|
|
|
public Task ExecuteAsync(string[] args, CancellationToken ct)
|
|
{
|
|
var table = new Table()
|
|
.Border(TableBorder.Rounded)
|
|
.BorderColor(Color.Grey)
|
|
.AddColumn(new TableColumn("[dim]Setting[/]").NoWrap())
|
|
.AddColumn(new TableColumn("[dim]Value[/]"));
|
|
|
|
table.AddRow("[grey]Model[/]", $"[cyan]{Markup.Escape(_model)}[/]");
|
|
table.AddRow("[grey]Endpoint[/]", $"[blue]{Markup.Escape(_endpoint)}[/]");
|
|
table.AddRow("[grey]Version[/]", $"[magenta]{Assembly.GetExecutingAssembly().GetName().Version}[/]");
|
|
table.AddRow("[grey]CWD[/]", $"[green]{Markup.Escape(Environment.CurrentDirectory)}[/]");
|
|
|
|
AnsiConsole.Write(table);
|
|
AnsiConsole.WriteLine();
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|