Skip to content

Latest commit

 

History

History
346 lines (321 loc) · 29.4 KB

Migrating.md

File metadata and controls

346 lines (321 loc) · 29.4 KB

Migrating from previous versions of Ookii.CommandLine

Ookii.CommandLine can introduce breaking changes when the major version number changes. This document outlines all the breaking changes in each major version.

Minor version number or revision changes are guaranteed to not have any breaking changes from their corresponding major version release.

Although there are quite a few changes, it's likely your application will not require many modifications unless you used subcommands, heavily customized the usage help format, or used custom argument value conversion.

Ookii.CommandLine 5.0

Version 5.0 was used as a cleanup release, tidying up the API and removing some elements that were left for compatibility. As a result, you may need to make some changes if you used certain features, though the scope of the changes is likely to be small.

Breaking API changes in version 5.0

Breaking behavior changes in version 5.0

Ookii.CommandLine 4.0

Breaking API changes in version 4.0

Breaking behavior changes in version 4.0

  • By default, both : and = are accepted as argument name/value separators.
  • The default value of ParseOptions.ShowUsageOnError has changed to UsageHelpRequest.SyntaxOnly.
  • Automatic prefix aliases are enabled by default for both argument names and command names.
  • The CommandManager, when using an assembly that is not the calling assembly, will only use public command classes, where before it would also use internal ones. This is to better respect access modifiers, and to make sure generated and reflection-based command managers behave the same.

Ookii.CommandLine 3.0

.Net Framework support

As of version 3.0, .Net Framework 2.0 is no longer supported. You can still target .Net Framework 4.6.1 and later using the .Net Standard 2.0 assembly. If you need to support an older version of .Net, please continue to use version 2.4.

Breaking API changes in version 3.0

  • It's strongly recommended to switch to the static CommandLineParser.Parse<T>() method, if you were not already using it from version 2.4.
  • If you do need to manually handle errors, be aware of the following changes:
  • The WriteUsageOptions class has been replaced with UsageWriter.
  • Usage options that previously were formatting strings now require creating a class that derives from UsageWriter and overrides some of its methods. You have much more control over the formatting this way. See customizing the usage help.
  • The CommandLineParser.WriteUsageToConsole() method no longer exists; instead, the CommandLineParser.WriteUsage() method will write to the console when invoked using a UsageWriter with no explicitly set output.
  • The subcommand (formerly called "shell command") API has had substantial changes.
  • A number of explicit method overloads have been removed in favor of optional parameters.
  • The CommandLineArgument.ElementType property now returns the underlying type for arguments using the Nullable<T> type.

Breaking behavior changes in version 3.0

  • Argument type conversion now defaults to CultureInfo.InvariantCulture, instead of CurrentCulture. This change was made to ensure a consistent parsing experience regardless of the user's regional settings. Only change it if you have a good reason.
  • CommandLineParser automatically adds -Help and -Version arguments by default. If you had arguments with these names, this will not affect you. The -Version argument is not added for subcommands.
  • CommandManager automatically adds a version command by default. If you had a command with this name, this will not affect you.
  • The usage help now includes aliases and default values by default.
  • The default format for showing aliases in the usage help has changed.
  • Usage help uses color output by default (where supported).
  • The LineWrappingTextWriter class does not count virtual terminal sequences as part of the line length by default.

Breaking changes in version 2.0

Ookii.CommandLine 2.0 and newer versions have substantial changes from version 1.0 and are not designed to be backwards compatible. There are changes in argument parsing behavior and API names and usage.

Upgrading an existing project that is using Ookii.CommandLine 1.0 to Ookii.CommandLine 2.0 or newer may require substantial code changes and may change how command lines are parsed.