1
0

initial commit

This commit is contained in:
2026-03-04 07:59:35 +01:00
commit 3ceb0e4884
27 changed files with 2280 additions and 0 deletions

44
SetupTui.cs Normal file
View File

@@ -0,0 +1,44 @@
using Spectre.Console;
namespace AnchorCli;
internal static class SetupTui
{
public static void Run()
{
var config = AnchorConfig.Load();
AnsiConsole.Write(new Rule("[cornflowerblue]anchor setup[/]").LeftJustified());
AnsiConsole.WriteLine();
// ── API Key ───────────────────────────────────────────────────
string maskedKey = config.ApiKey.Length > 8
? config.ApiKey[..4] + new string('*', config.ApiKey.Length - 8) + config.ApiKey[^4..]
: config.ApiKey.Length > 0 ? "****" : "[dim](not set)[/]";
AnsiConsole.MarkupLine($" Current API key: [dim]{Markup.Escape(maskedKey)}[/]");
string newKey = AnsiConsole.Prompt(
new TextPrompt<string>(" New API key [dim](Enter to keep)[/]:")
.AllowEmpty()
.Secret('*'));
if (!string.IsNullOrWhiteSpace(newKey))
config.ApiKey = newKey.Trim();
AnsiConsole.WriteLine();
// ── Model ─────────────────────────────────────────────────────
AnsiConsole.MarkupLine($" Current model: [cyan]{Markup.Escape(config.Model)}[/]");
string newModel = AnsiConsole.Prompt(
new TextPrompt<string>(" New model [dim](Enter to keep)[/]:")
.AllowEmpty());
if (!string.IsNullOrWhiteSpace(newModel))
config.Model = newModel.Trim();
// ── Save ──────────────────────────────────────────────────────
AnsiConsole.WriteLine();
config.Save();
AnsiConsole.MarkupLine("[green]✓ Config saved.[/]");
}
}