Skip to content

Commit 39dd8db

Browse files
authored
Merge pull request #2762 from scala-steward-org/topic/allow-multiple-url-checker-test-urls
Allow `--url-checker-test-url` option multiple times
2 parents 88aa0e3 + 581f457 commit 39dd8db

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

docs/help.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All command line arguments for the `scala-steward` application.
55
```
66
Usage:
77
scala-steward validate-repo-config
8-
scala-steward --workspace <file> --repos-file <file> [--git-author-name <string>] --git-author-email <string> [--git-author-signing-key <string>] --git-ask-pass <file> [--sign-commits] [--vcs-type <vcs-type>] [--vcs-api-host <uri>] --vcs-login <string> [--do-not-fork] [--add-labels] [--ignore-opts-files] [--env-var <name=value>]... [--process-timeout <duration>] [--whitelist <string>]... [--read-only <string>]... [--enable-sandbox | --disable-sandbox] [--max-buffer-size <integer>] [--repo-config <uri>]... [--disable-default-repo-config] [--scalafix-migrations <uri>]... [--disable-default-scalafix-migrations] [--artifact-migrations <uri>]... [--disable-default-artifact-migrations] [--cache-ttl <duration>] [--bitbucket-server-use-default-reviewers] [--gitlab-merge-when-pipeline-succeeds] [--gitlab-required-reviewers <integer>] [--github-app-id <integer> --github-app-key-file <file>] [--url-checker-test-url <uri>] [--default-maven-repo <string>] [--refresh-backoff-period <duration>]
8+
scala-steward --workspace <file> --repos-file <file> [--git-author-name <string>] --git-author-email <string> [--git-author-signing-key <string>] --git-ask-pass <file> [--sign-commits] [--vcs-type <vcs-type>] [--vcs-api-host <uri>] --vcs-login <string> [--do-not-fork] [--add-labels] [--ignore-opts-files] [--env-var <name=value>]... [--process-timeout <duration>] [--whitelist <string>]... [--read-only <string>]... [--enable-sandbox | --disable-sandbox] [--max-buffer-size <integer>] [--repo-config <uri>]... [--disable-default-repo-config] [--scalafix-migrations <uri>]... [--disable-default-scalafix-migrations] [--artifact-migrations <uri>]... [--disable-default-artifact-migrations] [--cache-ttl <duration>] [--bitbucket-server-use-default-reviewers] [--gitlab-merge-when-pipeline-succeeds] [--gitlab-required-reviewers <integer>] [--github-app-id <integer> --github-app-key-file <file>] [--url-checker-test-url <uri>]... [--default-maven-repo <string>] [--refresh-backoff-period <duration>]
99
1010
1111
@@ -77,7 +77,7 @@ Options and flags:
7777
--github-app-key-file <file>
7878
GitHub application key file
7979
--url-checker-test-url <uri>
80-
default: https://github.com
80+
URL for testing the UrlChecker at start-up (can be used multiple times); default: https://github.com
8181
--default-maven-repo <string>
8282
default: https://repo1.maven.org/maven2/
8383
--refresh-backoff-period <duration>

modules/core/src/main/scala/org/scalasteward/core/application/Cli.scala

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ import org.http4s.syntax.literals._
2626
import org.scalasteward.core.application.Config._
2727
import org.scalasteward.core.data.Resolver
2828
import org.scalasteward.core.git.Author
29+
import org.scalasteward.core.util.Nel
2930
import org.scalasteward.core.util.dateTime.renderFiniteDuration
3031
import org.scalasteward.core.vcs.VCSType
3132
import org.scalasteward.core.vcs.VCSType.GitHub
3233
import org.scalasteward.core.vcs.github.GitHubApp
33-
3434
import scala.concurrent.duration._
3535

3636
object Cli {
@@ -62,6 +62,8 @@ object Cli {
6262
Validated.fromEither(VCSType.parse(s)).toValidatedNel
6363
}
6464

65+
private val multiple = "(can be used multiple times)"
66+
6567
private val workspace: Opts[File] =
6668
option[File]("workspace", "Location for cache and temporary files")
6769

@@ -124,7 +126,7 @@ object Cli {
124126
).orFalse
125127

126128
private val envVar: Opts[List[EnvVar]] = {
127-
val help = "Assigns the value to the environment variable name (can be used multiple times)"
129+
val help = s"Assigns the value to the environment variable name $multiple"
128130
options[EnvVar]("env-var", help).orEmpty
129131
}
130132

@@ -138,13 +140,13 @@ object Cli {
138140
private val whitelist: Opts[List[String]] =
139141
options[String](
140142
"whitelist",
141-
"Directory white listed for the sandbox (can be used multiple times)"
143+
s"Directory white listed for the sandbox $multiple"
142144
).orEmpty
143145

144146
private val readOnly: Opts[List[String]] =
145147
options[String](
146148
"read-only",
147-
"Read only directory for the sandbox (can be used multiple times)"
149+
s"Read only directory for the sandbox $multiple"
148150
).orEmpty
149151

150152
private val enableSandbox: Opts[Boolean] =
@@ -167,7 +169,7 @@ object Cli {
167169
(envVar, processTimeout, sandboxCfg, maxBufferSize).mapN(ProcessCfg.apply)
168170

169171
private val repoConfig: Opts[List[Uri]] =
170-
options[Uri]("repo-config", "Additional repo config file (can be used multiple times)").orEmpty
172+
options[Uri]("repo-config", s"Additional repo config file $multiple").orEmpty
171173

172174
private val disableDefaultRepoConfig: Opts[Boolean] =
173175
flag("disable-default-repo-config", "Whether to disable the default repo config file").orFalse
@@ -178,7 +180,7 @@ object Cli {
178180
private val scalafixMigrations: Opts[List[Uri]] =
179181
options[Uri](
180182
"scalafix-migrations",
181-
"Additional scalafix migrations configuration file (can be used multiple times)"
183+
s"Additional scalafix migrations configuration file $multiple"
182184
).orEmpty
183185

184186
private val disableDefaultScalafixMigrations: Opts[Boolean] =
@@ -193,7 +195,7 @@ object Cli {
193195
private val artifactMigrations: Opts[List[Uri]] =
194196
options[Uri](
195197
"artifact-migrations",
196-
"Additional artifact migration configuration file (can be used multiple times)"
198+
s"Additional artifact migration configuration file $multiple"
197199
).orEmpty
198200

199201
private val disableDefaultArtifactMigrations: Opts[Boolean] =
@@ -251,9 +253,12 @@ object Cli {
251253
option[FiniteDuration]("refresh-backoff-period", help).withDefault(default)
252254
}
253255

254-
private val urlCheckerTestUrl: Opts[Uri] = {
256+
private val urlCheckerTestUrls: Opts[Nel[Uri]] = {
255257
val default = uri"https://github.com"
256-
option[Uri]("url-checker-test-url", s"default: $default").withDefault(default)
258+
options[Uri](
259+
"url-checker-test-url",
260+
s"URL for testing the UrlChecker at start-up $multiple; default: $default"
261+
).withDefault(Nel.one(default))
257262
}
258263

259264
private val defaultMavenRepo: Opts[Resolver] = {
@@ -286,7 +291,7 @@ object Cli {
286291
bitbucketServerCfg,
287292
gitLabCfg,
288293
gitHubApp,
289-
urlCheckerTestUrl,
294+
urlCheckerTestUrls,
290295
defaultMavenRepo,
291296
refreshBackoffPeriod
292297
).mapN(Config.apply)

modules/core/src/main/scala/org/scalasteward/core/application/Config.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ final case class Config(
6666
bitbucketServerCfg: BitbucketServerCfg,
6767
gitLabCfg: GitLabCfg,
6868
githubApp: Option[GitHubApp],
69-
urlCheckerTestUrl: Uri,
69+
urlCheckerTestUrls: Nel[Uri],
7070
defaultResolver: Resolver,
7171
refreshBackoffPeriod: FiniteDuration
7272
) {

modules/core/src/main/scala/org/scalasteward/core/application/SelfCheckAlg.scala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ final class SelfCheckAlg[F[_]](config: Config)(implicit
6262
s"Failed to execute $binary -- make sure it is on the PATH; following the detailed exception:"
6363

6464
private def checkUrlChecker: F[Unit] =
65-
for {
66-
_ <- F.unit
67-
url = config.urlCheckerTestUrl
68-
urlExists <- urlChecker.exists(url)
69-
msg = s"Self check of UrlChecker failed: checking that $url exists failed"
70-
_ <- F.whenA(!urlExists)(logger.warn(msg))
71-
} yield ()
65+
config.urlCheckerTestUrls.traverse_ { url =>
66+
urlChecker.exists(url).flatMap { urlExists =>
67+
val msg = s"Self check of UrlChecker failed: checking that $url exists failed"
68+
F.whenA(!urlExists)(logger.warn(msg))
69+
}
70+
}
7271
}

0 commit comments

Comments
 (0)