esamson / better-xdg   1.0

GNU General Public License v3.0 only GitHub

better-files + lightbend/config + XDG Base Directory Specification

Scala versions: 3.x

better-xdg

A Scala combo of better-files + lightbend/config + XDG Base Directory Specification.

Add to your dependencies.

Latest release is available from Maven Central.

version

libraryDependencies += "ph.samson.xdg" %% "basedir" % version

Use in your code.

import ph.samson.xdg.basedir._

object MyApp {
  def main(args: Array[String]): Unit = {

    // Get the base data directory
    val dataDir = data("my_app").get

    // Get a file from the data directory
    val dataFile = data("my_app").get("file")
  
    // Lookup all files from data directories
    val dataFiles = data("my_app").lookup("file")

    // Load application.conf
    val appConf = config("my_app").load

    // Load other.conf
    val otherConf = config("my_app").load("other.conf")

    // Get a file from the cache directory
    val cacheFile = cache("my_app").get("file")

    // Runtime dir may not be available if $XDG_RUNTIME_DIR is not set
    val runFile = runtime("my_app").get("file")
  }
}