with one click
scala-cli-deprecating-features
// Deprecate CLI options, option aliases, using directives, sub-commands, or config keys in Scala CLI. Use when marking a feature as deprecated with a warning.
// Deprecate CLI options, option aliases, using directives, sub-commands, or config keys in Scala CLI. Use when marking a feature as deprecated with a warning.
Add or change using directives in Scala CLI. Use when adding a new //> using directive, registering a directive handler, or editing directive preprocessing.
Add or run Scala CLI integration tests. Use when adding integration tests, debugging RunTests/CompileTests/etc., or working in modules/integration.
| name | scala-cli-deprecating-features |
| description | Deprecate CLI options, option aliases, using directives, sub-commands, or config keys in Scala CLI. Use when marking a feature as deprecated with a warning. |
All deprecation mechanisms emit aggregated warnings (single consolidated message) via Logger.deprecationWarning / Logger.flushDeprecationWarnings, respecting suppression via --suppress-deprecated-warnings or config suppress-warning.deprecated-features true.
The formatter always prefixes with the exact name used and the feature type:
[warn] `--foo` option is deprecated. Use --bar instead.\nDeprecated features may be removed in a future version.The message/detail passed by callers should NOT repeat the feature name โ only provide the reason or migration hint. Pass "" for no extra detail.
In the options case class, add @Tag(tags.deprecatedOption("detail")) or @Tag(tags.deprecatedOption) (no detail):
@Tag(tags.deprecatedOption("Use --bar instead."))
foo: Option[Boolean] = None,
RestrictedCommandsParser via arg.isDeprecatedOptionAdd @Tag(tags.deprecated("aliasName")) alongside the @Name("aliasName"):
@Name("oldAlias")
@Tag(tags.deprecated("oldAlias"))
myOption: Option[Boolean] = None,
Add an entry to DeprecatedDirectives.deprecatedCombinationsAndReplacements in modules/build/.../preprocessing/DeprecatedDirectives.scala:
// Key swap (e.g. lib โ dep):
DirectiveTemplate(Seq("oldKey"), None) -> keyReplacement("newKey")(
deprecatedWarning("oldKey", "newKey")
)
// Deprecated for removal (no replacement):
DirectiveTemplate(Seq("removedKey"), None) -> noReplacement(
deprecatedWarningForRemoval("removedKey")
)
keyReplacement / valueReplacement โ swap to a new key or value, emits a TextEdit for IDE quick-fixnoReplacement โ deprecated for removal, no TextEdit offeredDiagnostic (supports BSP with source locations)Override deprecationMessage in the command object (detail only, name is auto-prefixed):
object MyCommand extends ScalaCommand[MyOptions] {
override def deprecationMessage: Option[String] =
Some("Use other-command instead.")
}
For deprecating only a specific command alias, override deprecatedNames:
override def deprecatedNames: Set[List[String]] = Set(List("old-alias"))
Pass deprecationMessage to the Key constructor (currently supported on BooleanEntry):
val myKey = new Key.BooleanEntry(
prefix = Seq("my"),
name = "key",
specificationLevel = SpecificationLevel.IMPLEMENTATION,
description = "...",
deprecationMessage = Some("Use my.new-key instead.")
)
Config.scala when the key is accessed./mill -i __.compile./mill -i 'generate-reference-doc[]'.run (deprecated options/aliases are marked in reference docs)