using NozCli; using NozCli.Core.Config; using NozCli.Repl; using Spectre.Console; // ── noz --version / -v ─────────────────────────────────────────────────────── if (args is ["--version"] or ["-v"] or ["version"]) { Console.WriteLine($"noz {VersionInfo.Full}"); return 0; } // ── noz init ──────────────────────────────────────────────────── if (args is ["init", var url, var token]) { var isLocalhost = url.StartsWith("http://localhost", StringComparison.OrdinalIgnoreCase) || url.StartsWith("http://127.", StringComparison.OrdinalIgnoreCase); if (!isLocalhost && !url.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) { AnsiConsole.MarkupLine("[red]Error:[/] Only HTTPS servers are allowed (localhost HTTP is ok for dev)."); return 1; } var cfg = new LocalConfig { ServerUrl = url, Token = token }; cfg.Save(); AnsiConsole.MarkupLine($"[green]✓[/] Config saved → ~/.config/noz/config.json"); return 0; } // ── All other commands need a saved config ──────────────────────────────────── var config = LocalConfig.Load(); if (config is null) { AnsiConsole.MarkupLine("[red]Not initialised.[/] Run: [cyan]noz init [/]"); return 1; } // ── Interactive REPL ────────────────────────────────────────────────────────── await ReplSession.RunAsync(config); return 0;