Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace case-app with decline #2414

Merged
merged 4 commits into from
Dec 22, 2021
Merged

Replace case-app with decline #2414

merged 4 commits into from
Dec 22, 2021

Conversation

fthomas
Copy link
Member

@fthomas fthomas commented Dec 19, 2021

This replaces case-app with decline for command-line arguments parsing. My main motivation for doing this was to get familiar with decline but it also has some benefits:

  • Help messages are ordinary values instead of annotations of fields. This means we can use variables and string interpolation in those messages which is currently not possible in annotation arguments. The biggest benefit here is that we don't need to repeat default values verbatim.
  • Relationships between different options can be expressed. For example, --enable-sandbox and --disable-sandbox are now mutually exclusive and it is a runtime error if both are specified. Similar, if one of the GitHub app option is specified, the other must be specified too and not doing so is again a runtime error.
  • decline does not use macros and therefore is already available for Scala 3:

The only downside I'm seeing so far is that defining the options is a little bit more work than than writing the Args case class.

@fthomas fthomas added the enhancement New feature or request label Dec 19, 2021
@fthomas fthomas added this to the 0.14.0 milestone Dec 19, 2021
@codecov
Copy link

codecov bot commented Dec 19, 2021

Codecov Report

Merging #2414 (b0b8d2f) into master (2595822) will increase coverage by 0.50%.
The diff coverage is 97.45%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2414      +/-   ##
==========================================
+ Coverage   80.31%   80.81%   +0.50%     
==========================================
  Files         141      141              
  Lines        2393     2445      +52     
  Branches       53       53              
==========================================
+ Hits         1922     1976      +54     
+ Misses        471      469       -2     
Impacted Files Coverage Δ
...re/src/main/scala/org/scalasteward/core/Main.scala 0.00% <0.00%> (ø)
...ala/org/scalasteward/core/application/Config.scala 100.00% <ø> (+2.32%) ⬆️
...la/org/scalasteward/core/application/Context.scala 70.58% <ø> (+1.02%) ⬆️
...main/scala/org/scalasteward/core/vcs/VCSType.scala 100.00% <ø> (ø)
.../scala/org/scalasteward/core/application/Cli.scala 100.00% <100.00%> (ø)
...in/scala/org/scalasteward/core/util/dateTime.scala 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2595822...b0b8d2f. Read the comment docs.

@fthomas fthomas merged commit 1beab3a into master Dec 22, 2021
@fthomas fthomas deleted the topic/decline branch December 22, 2021 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant