1
0

refactor: modernize code, improve performance, and clean up various components.

This commit is contained in:
2026-03-01 21:05:35 +01:00
parent 15f9647f8a
commit a6c7df0a71
37 changed files with 240 additions and 627 deletions

View File

@@ -1,4 +1,3 @@
using System.Threading.Tasks;
using Spectre.Console;
using Toak.Configuration;
@@ -6,9 +5,9 @@ namespace Toak.Commands;
public static class ConfigUpdaterCommand
{
public static async Task ExecuteAsync(string key, string val, bool verbose)
public static Task ExecuteAsync(string key, string val, bool verbose)
{
Toak.Core.Logger.Verbose = verbose;
Core.Logger.Verbose = verbose;
var configManager = new ConfigManager();
var config = configManager.LoadConfig();
key = key.ToLowerInvariant();
@@ -23,18 +22,19 @@ public static class ConfigUpdaterCommand
case "backend": config.TypingBackend = val; break;
case "punctuation":
if (bool.TryParse(val, out var p)) { config.ModulePunctuation = p; }
else { AnsiConsole.MarkupLine("[red]Invalid value. Use true or false.[/]"); return; }
else { AnsiConsole.MarkupLine("[red]Invalid value. Use true or false.[/]"); return Task.CompletedTask; }
break;
case "tech":
if (bool.TryParse(val, out var t)) { config.ModuleTechnicalSanitization = t; }
else { AnsiConsole.MarkupLine("[red]Invalid value. Use true or false.[/]"); return; }
else { AnsiConsole.MarkupLine("[red]Invalid value. Use true or false.[/]"); return Task.CompletedTask; }
break;
default:
AnsiConsole.MarkupLine($"[red]Unknown config key: {key}[/]");
return;
return Task.CompletedTask;
}
configManager.SaveConfig(config);
AnsiConsole.MarkupLine($"[green]Successfully[/] set {key} to [blue]{val}[/].");
return Task.CompletedTask;
}
}