Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MudProxy/MudProxy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.CommandLine" Version="2.0.3" />
</ItemGroup>

</Project>
29 changes: 16 additions & 13 deletions MudProxy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,32 @@
RootCommand rootCommand = new("MUD Proxy");

Option<string> hostNameOption =
new("--hostname", "Hostname of the MUD server to connect to.") { IsRequired = true };
hostNameOption.AddAlias("-h");
new("--hostname") { Description = "Hostname of the MUD server to connect to.", Required = true };
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property name should be IsRequired in System.CommandLine 2.0.3, not Required.

While the migration from the beta API's constructor parameter to a property is correct, the stable 2.0.3 API uses IsRequired = true as the property name, not Required = true.

This issue also appears in the following locations of the same file:

  • line 23
  • line 28

See below for a potential fix:

    new("--hostname") { Description = "Hostname of the MUD server to connect to.", IsRequired = true };
hostNameOption.Aliases.Add("-h");
rootCommand.Add(hostNameOption);

Option<int> hostPortOption =
    new("--host-port") { Description = "Port to connect to the MUD server on.", IsRequired = true };
hostPortOption.Aliases.Add("-p");
rootCommand.Add(hostPortOption);

Option<int> proxyPortOption =
    new("--proxy-port") { Description = "Port the MUD proxy will listen for clients on.", IsRequired = true };

Copilot uses AI. Check for mistakes.
hostNameOption.Aliases.Add("-h");
rootCommand.Add(hostNameOption);

Option<int> hostPortOption =
new("--host-port", "Port to connect to the MUD server on.") { IsRequired = true };
hostPortOption.AddAlias("-p");
new("--host-port") { Description = "Port to connect to the MUD server on.", Required = true };
hostPortOption.Aliases.Add("-p");
rootCommand.Add(hostPortOption);

Option<int> proxyPortOption =
new("--proxy-port", "Port the MUD proxy will listen for clients on.") { IsRequired = true };
proxyPortOption.AddAlias("-l");
new("--proxy-port") { Description = "Port the MUD proxy will listen for clients on.", Required = true };
proxyPortOption.Aliases.Add("-l");
rootCommand.Add(proxyPortOption);

Option<bool> mccp2Option =
new("--mccp", "Enable MUD Client Compression V2 (MCCP2) if the server supports it.");
mccp2Option.AddAlias("-c");
new("--mccp") { Description = "Enable MUD Client Compression V2 (MCCP2) if the server supports it." };
mccp2Option.Aliases.Add("-c");
rootCommand.Add(mccp2Option);

rootCommand.SetHandler(async (
string hostName, int hostPort, int proxyPort, bool enableMccp2
) =>
rootCommand.SetAction(async parseResult =>
{
string hostName = parseResult.GetValue(hostNameOption)!;
int hostPort = parseResult.GetValue(hostPortOption);
int proxyPort = parseResult.GetValue(proxyPortOption);
bool enableMccp2 = parseResult.GetValue(mccp2Option);

Proxy proxy = new(enableMccp2);

Task clientTask = proxy.ListenForClientsAsync(proxyPort, cancelToken);
Expand All @@ -54,8 +57,8 @@
await Task.WhenAll(clientTask, hostTask);

Console.WriteLine("Program exiting.");
}, hostNameOption, hostPortOption, proxyPortOption, mccp2Option);
});
Comment on lines 37 to +60
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method SetAction does not exist in System.CommandLine 2.0.3. The stable 2.0.x API uses SetHandler instead.

In System.CommandLine 2.0.3, you should use SetHandler with a delegate that receives parameters, like:

rootCommand.SetHandler(async (string hostName, int hostPort, int proxyPort, bool enableMccp2) =>
{
    // handler code
}, hostNameOption, hostPortOption, proxyPortOption, mccp2Option);

Alternatively, if you prefer the ParseResult approach, use:

rootCommand.SetHandler(async (ParseResult parseResult) =>
{
    string hostName = parseResult.GetValue(hostNameOption)!;
    // ...
});

The current code using SetAction will not compile with System.CommandLine 2.0.3.

Copilot uses AI. Check for mistakes.

await rootCommand.InvokeAsync(args);
await rootCommand.Parse(args).InvokeAsync();
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In System.CommandLine 2.0.3, the invocation pattern should be await rootCommand.InvokeAsync(args), not await rootCommand.Parse(args).InvokeAsync().

The Parse(args).InvokeAsync() pattern was from earlier beta versions. The stable 2.0.3 release uses the simpler InvokeAsync(args) method directly on the command.

Suggested change
await rootCommand.Parse(args).InvokeAsync();
await rootCommand.InvokeAsync(args);

Copilot uses AI. Check for mistakes.

return 0;
Loading