Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jul 10, 2025

This PR completes the migration of all command handlers from System.CommandLine 2.0.0-beta4 to 2.0.0-beta5, implementing the breaking API changes required for the new version.

Changes Made

Package Update

  • Updated System.CommandLine package reference from 2.0.0-beta4.22272.1 to 2.0.0-beta5.25306.1

API Migration Patterns Applied

All 7 command handlers were systematically updated with the following changes:

Option Creation:

// Before (beta4)
var option = new Option<DirectoryInfo>(
    aliases: ["--project", "-p"],
    description: "Description here"
) { IsRequired = true };

// After (beta5)
var option = new Option<DirectoryInfo>("--project", "-p")
{
    Description = "Description here",
    Required = true
};

Command Setup:

// Before (beta4)
command.AddOption(option);
command.SetHandler(async (DirectoryInfo path) => { ... }, option);

// After (beta5)
command.Options.Add(option);
command.SetAction((ParseResult parseResult) =>
{
    var path = parseResult.GetValue(option);
    // ... handler logic
    return handlerMethod(path!);
});

Subcommands:

// Before (beta4)
parentCommand.AddCommand(subCommand);

// After (beta5)
parentCommand.Subcommands.Add(subCommand);

Updated Command Handlers

  1. InitProjectCommandHandler - Basic option handling patterns
  2. ExtractModelCommandHandler - Multiple boolean options with defaults
  3. QueryModelCommandHandler - Simple command pattern
  4. ShowObjectCommandHandler - Complex subcommands (table/view/storedprocedure)
  5. ExportModelCommandHandler - File type options with default values
  6. EnrichModelCommandHandler - Multiple subcommands with complex option handling
  7. DataDictionaryCommandHandler - Nested subcommand structure with required options

Program.cs Updates

  • Updated main command registration to use rootCommand.Subcommands.Add()
  • Modified main method signature and invocation pattern for beta5 compatibility

Key API Changes

  • IsRequired = trueRequired = true
  • AddOption()Options.Add()
  • AddCommand()Subcommands.Add()
  • SetHandler()SetAction()
  • ✅ Handler signatures now use ParseResult parameter
  • parseResult.GetValue<T>(option) for retrieving option values
  • ArgumentHelpNameHelpName property
  • ✅ Option constructors use positional parameters, Description as property

Validation

  • ✅ All command handlers compile without errors
  • ✅ Project builds successfully with System.CommandLine 2.0.0-beta5
  • ✅ Command structure and option handling preserved
  • ✅ Subcommand hierarchies maintained (DataDictionary, EnrichModel, ShowObject)

The migration maintains full backward compatibility of the CLI interface while updating the internal implementation to use the new System.CommandLine beta5 API patterns.

Fixes #18.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] [Chore]: Migrate all command handlers to System.CommandLine 2.0.0-beta5 API Migrate all command handlers to System.CommandLine 2.0.0-beta5 API Jul 10, 2025
@Copilot Copilot AI requested a review from ahmedig July 10, 2025 04:13
Copilot finished work on behalf of ahmedig July 10, 2025 04:13
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 all command handlers to System.CommandLine 2.0.0-beta5 API

2 participants