Skip to content

Commit

Permalink
Parse subpath
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszwawrzyk committed Oct 31, 2024
1 parent 92d78b1 commit 793a109
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/main/scala/com/virtuslab/shared_indexes/config/MainConfig.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.virtuslab.shared_indexes.config

import mainargs.{ParserForClass, TokensReader}
import os.{FilePath, Path, RelPath}
import os.{FilePath, Path, RelPath, SubPath}
import mainargs.TokensReader.{OptionRead, Simple, tryEither}
import org.slf4j.event.Level

Expand All @@ -18,22 +18,22 @@ object MainConfig {
private object PathReader extends Simple[Path] {
override def shortName: String = "path"
override def read(strs: Seq[String]) = tryEither {
FilePath(strs.last) match {
case p: Path => p
case r: RelPath => os.pwd / r
}
stringToPath(strs.last)
}
}

private object PathsReader extends Simple[Seq[os.Path]] {
override def shortName: String = "paths"
override def read(strs: Seq[String]) = tryEither {
strs.map { str =>
FilePath(str) match {
case p: Path => p
case r: RelPath => os.pwd / r
}
}
strs.map(stringToPath)
}
}

private def stringToPath(str: String) = {
FilePath(str) match {
case p: Path => p
case r: RelPath => os.pwd / r
case s: SubPath => os.pwd / s
}
}

Expand Down

0 comments on commit 793a109

Please sign in to comment.