Skip to content

[Chore]: Migrate all command handlers to System.CommandLine 2.0.0-beta5 API #18

@ahmedig

Description

@ahmedig

Area

Application Services (API, Functions, etc.)

Motivation

All individual command handlers need to be migrated to use the new System.CommandLine 2.0.0-beta5 API patterns. This includes updating option creation, handler method signatures, and command setup patterns across 7 command handler classes.

The new version requires significant changes to:

  • Replace IsRequired = true with Required = true for options
  • Replace AddOption() with Options.Add() syntax
  • Replace SetHandler() with SetAction() method
  • Update handler signatures to use ParseResult parameter
  • Update ArgumentHelpName to HelpName property

Task Description

Update all individual command handlers to use the new System.CommandLine 2.0.0-beta5 API patterns. This affects 7 command handler classes that need systematic migration.

Command Handlers to Update:

  1. InitProjectCommandHandler.cs - Basic option handling patterns
  2. ExtractModelCommandHandler.cs - Multiple option handling
  3. DataDictionaryCommandHandler.cs - Complex subcommand structure
  4. EnrichModelCommandHandler.cs - Standard option patterns
  5. ExportModelCommandHandler.cs - File type option handling
  6. QueryModelCommandHandler.cs - Simple command pattern
  7. ShowObjectCommandHandler.cs - Standard option patterns

Common Changes Required for Each Handler:

  • Replace IsRequired = true with Required = true for options
  • Replace AddOption() with Options.Add() syntax
  • Replace AddCommand() with Subcommands.Add() for subcommands
  • Replace SetHandler() with SetAction() method
  • Update handler method signatures to use ParseResult parameter
  • Use parseResult.GetValue<T>(option) to get option values
  • Update ArgumentHelpName to HelpName property
  • Ensure async handlers include CancellationToken parameter

Acceptance Criteria

  • All 7 command handlers compile without errors
  • Option creation uses new constructor patterns and property setters
  • Handler methods use ParseResult parameter correctly
  • All commands execute successfully with test parameters
  • Help output displays correctly for all commands
  • Error handling and validation continue to work
  • Subcommands (DataDictionaryCommandHandler) work correctly
  • No regression in command-line functionality

Impact / Risk

Related Issues:

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions