- PublishAot=true, InvariantGlobalization=true, AssemblyName=noz - Version 0.1.0 baked into binary via AssemblyInformationalVersion - MSBuild target injects git short hash as SourceRevisionId at build time - macOS: LinkerArg for Homebrew OpenSSL path (required for AOT linking) - noz --version / -v exits cleanly without starting the REPL
40 lines
1.8 KiB
C#
40 lines
1.8 KiB
C#
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 <url> <token> ────────────────────────────────────────────────────
|
|
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 <server-url> <token>[/]");
|
|
return 1;
|
|
}
|
|
|
|
// ── Interactive REPL ──────────────────────────────────────────────────────────
|
|
await ReplSession.RunAsync(config);
|
|
return 0;
|