Skip to content

2.2.0

Latest

Choose a tag to compare

@alexarchambault alexarchambault released this 03 Nov 01:25
· 2 commits to main since this release
1684d1a

Highlights

  • Fewer supported targets. Scala 2.12 and the Cats Effect 2 module are gone. Scala.js, Scala Native and the cats module are now published only for Scala 3. See Breaking changes.
  • Better Scala 3 derivation. derives Parser, Help now works, and derivation gives clearer errors and handles more cases (see below).
  • Cats module on Scala Native. case-app-cats is now published for Scala Native too.

Breaking changes

These changes come from #676, unless noted otherwise.

  • Scala 2.12 is no longer supported. case-app 2.2.0 is published for Scala 2.13 and Scala 3 only.
  • The case-app-cats-effect-2 module is gone. Use case-app-cats, which is based on Cats Effect 3.
  • Scala.js, Scala Native and case-app-cats are published only for Scala 3. On Scala 2.13, only the JVM case-app and case-app-annotations artifacts are still published.
  • The case-app-util module is no longer published. On Scala 2, its macros now ship inside the case-app JAR. On Scala 3 it had no content. If you depended on case-app-util directly, remove that dependency. case-app already provides what it contained.

New features and improvements

Scala 3 derivation (#697)

  • derives clauses. Parser and Help can now be derived with a derives clause:
    case class Options(
      foo: Int
    ) derives Parser, Help
    This replaces the old @derives[Parser, Help] object Options approach in the docs.
  • Clearer compile errors. When an instance is missing, derivation now fails with a message naming the field and the cause, such as Cannot parse field value of … or Cannot derive a parser for field value of …. Previously it could fail with an exception.
  • Large options classes. Derivation no longer overflows the compiler stack on classes with many fields (about 80 or more).
  • Default values.
    • Fields whose type has an implicit caseapp.core.default.Default (Option[T], List[T], Vector[T], counters, …) are now optional even without an explicit default value, as on Scala 2.
    • Default values now work for classes compiled separately and for case classes nested inside a class.
  • Annotation order. Repeated annotations such as @ExtraName and @Tag now keep their source order.
  • @AppName, @AppVersion, @ProgName, @ArgsName and @HelpMessage on the options class are read more reliably.
  • App name for a class named Options. Such a class now gets Options as its app name instead of an empty one.

Scala 3 binary compatibility (#697)

  • On Scala 3, case-app now uses a vendored copy of the unroll compiler plugin. It generates the binary-compatible constructor, apply and copy overloads that data-class generates on Scala 2. The plugin is used only at build time and is not published.
  • The with… setters from caseapp.core.Scala3Helpers, and those generated by @data on Scala 2, are deprecated. Use copy instead, which works on both Scala 2 and Scala 3. For example:
    // before
    helpFormat.withSortedGroups(Some(Seq("Help", "Main")))
    // after
    helpFormat.copy(sortedGroups = Some(Seq("Help", "Main")))
    You no longer need to import caseapp.core.Scala3Helpers._.

Platforms

  • case-app-cats is now published for Scala Native (#693).
  • MiMa binary compatibility checks now also run for the Scala Native modules (#687).

Bug fixes

  • "Already specified" error message (#686). When an option that accepts a single value was passed twice, the error read argument ??? already specified. It now names the argument, as in Argument --foo: specified more than once.
  • Custom name formatters (#696). A custom name formatter (Parser#nameFormatter) was applied only to the first field when reporting errors such as a missing required option. The other fields used the default formatter. All fields now use the custom formatter.

Dependency updates

  • cats-effect 3.7.1 (#678)
  • Scala 3.3.9 (#684)
  • os-lib 0.11.10 (#683)

Build, CI and tests

  • Build
    • Refactored the build to share source configuration across modules (#691)
    • Removed dead cross-source build code (#685)
    • Set the Mill JVM heap size to 4 GB (#682)
    • Updated Mill to 1.3.1 (#694)
    • Cleaned up the Scalafmt configuration (#698)
  • CI
    • Read the scalafmt version from .scalafmt.conf on CI (#688)
    • Added timeouts to CI jobs (#689)
    • Bumped actions/checkout to 7 (#679)
    • Bumped coursier/cache-action to 9.0 (#681, #695)
  • Tests
    • Added tests for the Cats IOCommand entry points (#690)
    • Ran the DSL expansion tests on both JVM and Native (#692)

Full Changelog: v2.1.1...v2.2.0