Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 11, 2025

Refactors Tool and Workload command subcommands to separate parsing structure from action binding, establishing clear separation of concerns.

Pattern

Each subcommand now follows:

  • XyzCommandDefinition.cs - Command structure (options, arguments) with Create() method. No action binding.
  • XyzCommandParser.cs - Calls Definition.Create() and binds action via SetAction(). Exposes backward-compatible static properties.
  • XyzCommand.cs - Unchanged execution logic.

Example

Before:

internal static class ToolSearchCommandParser
{
    public static readonly Option<bool> DetailOption = new("--detail") { ... };
    
    private static Command ConstructCommand()
    {
        Command command = new("search", ...);
        command.Options.Add(DetailOption);
        command.SetAction((parseResult) => new ToolSearchCommand(parseResult).Execute());
        return command;
    }
}

After:

// ToolSearchCommandDefinition.cs - Pure structure
internal static class ToolSearchCommandDefinition
{
    public static readonly Option<bool> DetailOption = new("--detail") { ... };
    
    public static Command Create()
    {
        Command command = new("search", ...);
        command.Options.Add(DetailOption);
        return command;  // No SetAction
    }
}

// ToolSearchCommandParser.cs - Action binding
internal static class ToolSearchCommandParser
{
    public static readonly Option<bool> DetailOption = ToolSearchCommandDefinition.DetailOption;
    
    private static Command ConstructCommand()
    {
        Command command = ToolSearchCommandDefinition.Create();
        command.SetAction((parseResult) => new ToolSearchCommand(parseResult).Execute());
        return command;
    }
}

Scope

Tool commands (8): install, update, uninstall, list, search, restore, run, execute

Workload commands (12): install, update, uninstall, list, search, search versions, restore, repair, clean, elevate, history, config

Notes

  • Maintains full backward compatibility via static property delegation in Parser classes
  • No changes to command execution logic or public APIs
  • Format commit added to .git-blame-ignore-revs

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • test.example.com
    • Triggering command: /home/REDACTED/work/sdk/sdk/artifacts/bin/redist/Debug/dotnet/dotnet /home/REDACTED/work/sdk/sdk/artifacts/bin/redist/Debug/dotnet/dotnet tool install -g fake-tool aller/sdk/11.0.100-dev/Microsoft.Build.Tasks.Core.dll sources.dll p/bin/chmod ources.dll resources.dll k/sdk/sdk/.dotne--depsfile chmod 644 ebug/dotnet-inst/home/REDACTED/work/sdk/sdk/.dotnet/sdk/10.0.100-rc.1.25451.107/DotnetTools/dotnet/home/REDACTED/work/sdk/sdk/artifacts/bin/redist/Debug/dotnet/dotnet ectedData.dll hmod esources.dll rces.dll k/sdk/sdk/.dotne--noprofile chmod (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Create PR against release/10.0.2xx branch that refactors subcommands of Tool and Workload commands using the following pattern:

XyzCommandDefinition.cs (parsing only)

  • Contains options, arguments, command structure
  • Create() method creates the command structure
  • No SetAction() calls
    XyzCommandParser.cs (actions only)
    GetCommand() returns the command with action
    XyzCommand.cs (implementation for more complex commands)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Refactor Tool and Workload command subcommands structure Separate command parsing from action binding in Tool and Workload subcommands Dec 11, 2025
Copilot AI requested a review from tmat December 11, 2025 22:29
@tmat tmat closed this Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants