From d3ca1f92976c76d68de901f3072a0e1583ea1905 Mon Sep 17 00:00:00 2001
From: Alexa <53471801+Alexa-RR@users.noreply.github.com>
Date: Tue, 16 Jun 2026 01:04:45 +0300
Subject: [PATCH] fix(cli): exit 0 on --help so CI smoke test passes (#13)
* fix(cli): exit 0 on --help, handle parse errors cleanly
--help printed usage but returned exit code 1, failing the CI smoke test. Treat --help / -h / no-args as a successful usage print (exit 0), and catch parser ArgumentExceptions so a missing value or bad --mode exits 1 with a message instead of an unhandled crash.
* fix(cli): declare RuntimeIdentifiers so no-restore publish works
CI restores without a RID then publishes per-RID with no-restore, which failed NETSDK1047 because the assets file had no RID targets. Declaring RuntimeIdentifiers makes the RID-less restore cover all of them.
---
.../DorkNet.ServerCli.csproj | 4 +
cli/DorkNet.ServerCli/Program.cs | 77 +++++++++++--------
2 files changed, 47 insertions(+), 34 deletions(-)
diff --git a/cli/DorkNet.ServerCli/DorkNet.ServerCli.csproj b/cli/DorkNet.ServerCli/DorkNet.ServerCli.csproj
index 0a62991..5f4ca0e 100644
--- a/cli/DorkNet.ServerCli/DorkNet.ServerCli.csproj
+++ b/cli/DorkNet.ServerCli/DorkNet.ServerCli.csproj
@@ -6,6 +6,10 @@
alongside Windows. The shared Backend classes are written to
OperatingSystem.IsWindows()-gate any Windows-only paths. -->
net9.0
+
+ win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64
enable
enable
DorkNet.ServerCli
diff --git a/cli/DorkNet.ServerCli/Program.cs b/cli/DorkNet.ServerCli/Program.cs
index d267d1b..e52f6b3 100644
--- a/cli/DorkNet.ServerCli/Program.cs
+++ b/cli/DorkNet.ServerCli/Program.cs
@@ -14,8 +14,15 @@ public static class Program
{
public static async Task Main(string[] args)
{
+ // --help / -h (and a bare invocation) print usage and exit cleanly.
+ if (args.Length == 0 || args.Contains("--help") || args.Contains("-h"))
+ {
+ PrintHelp();
+ return 0;
+ }
+
var parsed = ParseArgs(args);
- if (parsed is null) return 1; // ParseArgs already wrote --help or an error.
+ if (parsed is null) return 1; // ParseArgs already wrote the error.
// Validate required values up front so the user sees the
// failure before any download / process spin-up.
@@ -216,50 +223,52 @@ public static class Program
private static ParsedArgs? ParseArgs(string[] args)
{
- if (args.Length == 0 || args.Contains("--help") || args.Contains("-h"))
- {
- PrintHelp();
- return null;
- }
-
string photon = "", voice = "", region = "us";
string mode = "localtunnel", apex = "", name = "DorkNet Server";
string versionKey = "march_2020_03_10";
string? serverDir = null;
- for (int i = 0; i < args.Length; i++)
+ try
{
- string Next()
+ for (int i = 0; i < args.Length; i++)
{
- if (i + 1 >= args.Length)
- throw new ArgumentException($"missing value for {args[i]}");
- return args[++i];
+ string Next()
+ {
+ if (i + 1 >= args.Length)
+ throw new ArgumentException($"missing value for {args[i]}");
+ return args[++i];
+ }
+ switch (args[i])
+ {
+ case "--photon-id": photon = Next(); break;
+ case "--voice-id": voice = Next(); break;
+ case "--region": region = Next(); break;
+ case "--mode": mode = Next(); break;
+ case "--apex": apex = Next(); break;
+ case "--name": name = Next(); break;
+ case "--version": versionKey = Next(); break;
+ case "--server-dir": serverDir = Next(); break;
+ default:
+ Console.Error.WriteLine($"error: unknown arg '{args[i]}' (try --help)");
+ return null;
+ }
}
- switch (args[i])
+
+ HostingMode parsedMode = mode.ToLowerInvariant() switch
{
- case "--photon-id": photon = Next(); break;
- case "--voice-id": voice = Next(); break;
- case "--region": region = Next(); break;
- case "--mode": mode = Next(); break;
- case "--apex": apex = Next(); break;
- case "--name": name = Next(); break;
- case "--version": versionKey = Next(); break;
- case "--server-dir": serverDir = Next(); break;
- default:
- Console.Error.WriteLine($"error: unknown arg '{args[i]}' (try --help)");
- return null;
- }
+ "localtunnel" or "lt" or "internet" or "tunnel" => HostingMode.SingleOriginTunnel,
+ "wildcard" or "remote" or "tunnelto" => HostingMode.RemoteWildcard,
+ "lan" or "local" or "wifi" => HostingMode.LocalNetwork,
+ _ => throw new ArgumentException($"unknown --mode '{mode}' (try localtunnel, wildcard, lan)"),
+ };
+
+ return new ParsedArgs(photon, voice, region, parsedMode, apex, name, versionKey, serverDir);
}
-
- HostingMode parsedMode = mode.ToLowerInvariant() switch
+ catch (ArgumentException ex)
{
- "localtunnel" or "lt" or "internet" or "tunnel" => HostingMode.SingleOriginTunnel,
- "wildcard" or "remote" or "tunnelto" => HostingMode.RemoteWildcard,
- "lan" or "local" or "wifi" => HostingMode.LocalNetwork,
- _ => throw new ArgumentException($"unknown --mode '{mode}' (try localtunnel, wildcard, lan)"),
- };
-
- return new ParsedArgs(photon, voice, region, parsedMode, apex, name, versionKey, serverDir);
+ Console.Error.WriteLine($"error: {ex.Message} (try --help)");
+ return null;
+ }
}
private static void PrintHelp()