-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Summary
System.CommandLine 2.0.0-beta5 introduces several breaking changes that require code updates throughout the project. This issue tracks the migration effort.
References
Breaking changes to address
- Renaming:
- Several properties and types have been renamed (e.g.,
Option.IsRequired→Option.Required,Symbol.IsHidden→Symbol.Hidden, etc.). Parseris nowCommandLineParserand is a static class.
- Several properties and types have been renamed (e.g.,
- Mutable collections:
- Collections like
Arguments,Options,Subcommands,Validators, andAliasesare now mutable collections. Use.Add()and.Remove()directly instead ofAddArgument,AddOption, etc.
- Collections like
- Names and aliases:
- The name is now a mandatory parameter for all
Option<T>,Argument<T>, andCommandconstructors. Aliases are provided as params. The description must be set via theDescriptionproperty. - The
Aliasesproperty no longer includes the name itself.
- The name is now a mandatory parameter for all
- Default values and custom parsing:
- Use the
DefaultValueFactoryproperty for default values. - Use the
CustomParserproperty for custom parsing.
- Use the
- Handler and invocation:
SetHandleris nowSetAction.- The handler signature has changed: it now receives
ParseResult(and optionallyCancellationToken).InvocationContextwas removed. ICommandHandlerand related interfaces were removed.
- Configuration:
CommandLineBuilderand related APIs were replaced by a mutableCommandLineConfiguration.IConsoleand related interfaces were removed. UseTextWriterfor output.
- Parsing and invocation:
Command.Parsereturns aParseResult, which exposesInvokeandInvokeAsyncmethods.
- Global options
- The method
Command.AddGlobalOptionwas removed and now all global options should be added as a option on the parent/root command with the propertyRecursive = true
- The method
Migration steps
- Update all usages of renamed types and properties.
- Refactor all usages of
Command.InvokeAsync(args)toCommand.Parse(args).InvokeAsync(). - Refactor all usages of
AddArgument,AddOption, etc., to use the new mutable collectionsArguments.AddandOptions.Add. - Refactor all usages of
AddGlobalOptionto useOptions.Addand set the propertyRecursive = true - Update all
OptionandArgumentconstructors to provide the name and aliases as required. - Refactor command handlers to use
SetActionand update signatures to useParseResultandCancellationToken. - Update configuration and output handling to use the new APIs.
- Update tests and mocks to match the new API surface.
Acceptance criteria
- The project builds and all tests pass using System.CommandLine 2.0.0-beta5.
- Test coverage should aim to cover 100% of the code base. Minimum of 95% is acceptable.
- All obsolete API usages are removed.
This is a breaking change and will require coordinated updates across commands, tests, and startup/configuration code.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels