Skip to content

Commit cf59606

Browse files
Add --cache option
1 parent 182be4b commit cf59606

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

modules/cli/src/main/scala/scala/cli/commands/CoursierOptions.scala

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,22 @@ final case class CoursierOptions(
1212
@HelpMessage("Specify a TTL for changing dependencies, such as snapshots")
1313
@ValueDescription("duration|Inf")
1414
@Hidden
15-
ttl: Option[String] = None
15+
ttl: Option[String] = None,
16+
@Group("Dependency")
17+
@HelpMessage("Set the coursier cache location")
18+
@ValueDescription("path")
19+
@Hidden
20+
cache: Option[String] = None
1621
) {
1722
// format: on
1823
def coursierCache(logger: CacheLogger) = {
19-
val baseCache = FileCache()
20-
val ttl0 = ttl.map(_.trim).filter(_.nonEmpty).map(Duration(_)).orElse(baseCache.ttl)
24+
var baseCache = FileCache().withLogger(logger)
25+
val ttlOpt = ttl.map(_.trim).filter(_.nonEmpty).map(Duration(_))
26+
for (ttl0 <- ttlOpt)
27+
baseCache = baseCache.withTtl(ttl0)
28+
for (loc <- cache.filter(_.trim.nonEmpty))
29+
baseCache = baseCache.withLocation(loc)
2130
baseCache
22-
.withTtl(ttl0)
23-
.withLogger(logger)
2431
}
2532
}
2633

website/docs/reference/cli-options.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ Available in commands:
213213

214214
Specify a TTL for changing dependencies, such as snapshots
215215

216+
#### `--cache`
217+
218+
Set the coursier cache location
219+
216220
## Cross options
217221

218222
Available in commands:

0 commit comments

Comments
 (0)