Skip to content

Instantly share code, notes, and snippets.

@PKOfficial
Created February 16, 2024 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PKOfficial/79e6fc77e03702218cf894f642c52d71 to your computer and use it in GitHub Desktop.
Save PKOfficial/79e6fc77e03702218cf894f642c52d71 to your computer and use it in GitHub Desktop.
Tree like command using scala-cli
//> using dep "com.lihaoyi::os-lib:0.9.3"
import os._
object Tree extends App {
def listFiles(path: os.Path, depth: Int = 0): Unit = {
if (os.isDir(path)) {
for (subPath <- os.list(path)) {
println(" " * depth + subPath.last)
listFiles(subPath, depth + 1)
}
}
}
listFiles(os.pwd)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment