From 87124716336329db08b869d6e09030a29be08921 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Feb 2026 12:02:57 +0000 Subject: [PATCH 1/2] Initial plan From 0adae7734c1edff0b1806390077be5201db8f63c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Feb 2026 12:10:26 +0000 Subject: [PATCH 2/2] Compact error output, fix four-dash bug, and improve error messages - Suppress help text on parse errors using ParseErrorAction.ShowHelp = false - Fix four-dash bug in JwtCommand.cs: jwtSigningKeyOption.Name already includes '--' - Improve error messages across all validators for consistency: - Wrap invalid values in quotes for clarity - Add actionable hints (examples, allowed values) - Use consistent formatting pattern Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com> --- DevProxy/Commands/DevProxyCommand.cs | 17 ++++++++++++----- DevProxy/Commands/JwtCommand.cs | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/DevProxy/Commands/DevProxyCommand.cs b/DevProxy/Commands/DevProxyCommand.cs index c5c4b8b3..39794ad3 100644 --- a/DevProxy/Commands/DevProxyCommand.cs +++ b/DevProxy/Commands/DevProxyCommand.cs @@ -2,6 +2,7 @@ using DevProxy.Abstractions.Proxy; using DevProxy.Abstractions.Utils; using System.CommandLine; +using System.CommandLine.Invocation; using System.CommandLine.Parsing; using System.Globalization; @@ -165,6 +166,12 @@ public async Task InvokeAsync(string[] args, WebApplication app) var parseResult = IsStdioCommand ? StdioCommand.ParseStdioArgs(this, args) : Parse(args); + + if (parseResult.Action is ParseErrorAction parseErrorAction) + { + parseErrorAction.ShowHelp = false; + } + return await parseResult.InvokeAsync(app.Lifetime.ApplicationStopping); } @@ -237,7 +244,7 @@ private void ConfigureCommand() if (!File.Exists(filePath)) { - input.AddError($"Configuration file {filePath} does not exist"); + input.AddError($"Configuration file '{filePath}' does not exist. Check the file path and try again."); } }); @@ -250,7 +257,7 @@ private void ConfigureCommand() { if (!System.Net.IPAddress.TryParse(input.Tokens[0].Value, out _)) { - input.AddError($"{input.Tokens[0].Value} is not a valid IP address"); + input.AddError($"'{input.Tokens[0].Value}' is not a valid IP address. Example: 127.0.0.1"); } }); @@ -272,7 +279,7 @@ private void ConfigureCommand() { if (!Enum.TryParse(input.Tokens[0].Value, true, out _)) { - input.AddError($"{input.Tokens[0].Value} is not a valid log level. Allowed values are: {string.Join(", ", Enum.GetNames())}"); + input.AddError($"'{input.Tokens[0].Value}' is not a valid log level. Allowed values: {string.Join(", ", Enum.GetNames())}"); } }); @@ -354,7 +361,7 @@ private void ConfigureCommand() { if (!long.TryParse(input.Tokens[0].Value, out var timeoutInput) || timeoutInput < 1) { - input.AddError($"{input.Tokens[0].Value} is not valid as a timeout value"); + input.AddError($"'{input.Tokens[0].Value}' is not a valid timeout value. Specify a positive integer (in seconds)."); } } catch (InvalidOperationException ex) @@ -411,7 +418,7 @@ private void ConfigureCommand() } if (!Enum.TryParse(input.Tokens[0].Value, true, out _)) { - input.AddError($"{input.Tokens[0].Value} is not a valid log-for value. Allowed values are: {string.Join(", ", Enum.GetNames())}"); + input.AddError($"'{input.Tokens[0].Value}' is not a valid log-for value. Allowed values: {string.Join(", ", Enum.GetNames())}"); } }); diff --git a/DevProxy/Commands/JwtCommand.cs b/DevProxy/Commands/JwtCommand.cs index db197e72..416f7522 100644 --- a/DevProxy/Commands/JwtCommand.cs +++ b/DevProxy/Commands/JwtCommand.cs @@ -94,7 +94,7 @@ private void ConfigureCommand() var value = input.GetValue(jwtSigningKeyOption); if (string.IsNullOrWhiteSpace(value) || value.Length < 32) { - input.AddError($"Requires option '--{jwtSigningKeyOption.Name}' to be at least 32 characters"); + input.AddError($"Requires option '{jwtSigningKeyOption.Name}' to be at least 32 characters"); } } catch (InvalidOperationException ex)