Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jul 10, 2025

This PR migrates the main application entry point in Program.cs to use System.CommandLine 2.0.0-beta5 API patterns, addressing the breaking changes introduced in the beta5 release.

Changes Made

1. Package Update

  • Updated System.CommandLine from 2.0.0-beta4.22272.1 to 2.0.0-beta5.25277.114

2. Command Registration Migration

Replaced all rootCommand.AddCommand() calls with the new mutable collections pattern:

// Before (beta4)
rootCommand.AddCommand(InitProjectCommandHandler.SetupCommand(host));
rootCommand.AddCommand(DataDictionaryCommandHandler.SetupCommand(host));
// ... more commands

// After (beta5)
rootCommand.Subcommands.Add(InitProjectCommandHandler.SetupCommand(host));
rootCommand.Subcommands.Add(DataDictionaryCommandHandler.SetupCommand(host));
// ... more commands

3. Entry Point Modernization

Updated the main method to use the new parsing and invocation separation pattern:

// Before (beta4)
private static async Task Main(string[] args)
{
    // ... setup code
    await rootCommand.InvokeAsync(args);
}

// After (beta5)
private static async Task<int> Main(string[] args)
{
    // ... setup code
    var parseResult = rootCommand.Parse(args);
    return await parseResult.InvokeAsync();
}

Validation

  • ✅ Created isolated test confirming API patterns work correctly
  • ✅ Verified help functionality displays properly (--help)
  • ✅ Confirmed error handling returns appropriate exit codes
  • ✅ All 7 command registrations updated to use new syntax

Impact

  • Breaking Changes: Internal only - external CLI interface remains unchanged
  • Scope: Focused specifically on Program.cs entry point as requested
  • Compatibility: Maintains existing command-line behavior for end users

Fixes #16.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: ahmedig <102851+ahmedig@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] [Chore]: Migrate Program.cs to System.CommandLine 2.0.0-beta5 API [Chore]: Migrate Program.cs to System.CommandLine 2.0.0-beta5 API Jul 10, 2025
@Copilot Copilot AI requested a review from ahmedig July 10, 2025 04:04
Copilot finished work on behalf of ahmedig July 10, 2025 04:04
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.

[Chore]: Migrate Program.cs to System.CommandLine 2.0.0-beta5 API
2 participants