Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active May 25, 2024 10:18
Show Gist options
  • Save dacr/8f9abbe43017866c1ae9ecf88a530b7f to your computer and use it in GitHub Desktop.
Save dacr/8f9abbe43017866c1ae9ecf88a530b7f to your computer and use it in GitHub Desktop.
com-lihaoyi pprint basic usage examples / published by https://github.com/dacr/code-examples-manager #e3195c2d-66f5-403d-9332-cf907e34db04/4f1db5f6a97f7f5496c7aa6c6a4453a4cefab585
// summary : com-lihaoyi pprint basic usage examples
// keywords : scala, lihaoyi, pprint, @testable
// publish : gist
// authors : David Crosson
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
// id : e3195c2d-66f5-403d-9332-cf907e34db04
// created-on : 2024-01-06T12:25:07+01:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
// ---------------------
//> using scala "3.4.2"
//> using dep "com.lihaoyi::os-lib:0.9.3"
// ---------------------
val wd = os.pwd / "com-lihaoyi-os-lib-working-directory"
os.remove.all(wd)
os.makeDir.all(wd)
val file = wd / "file.txt"
val fileCopy = wd / "copied.txt"
os.write(file, "hello")
os.read(file)
os.copy(file, fileCopy)
assert(os.list(wd).size == 2)
val result = os.proc("cat", file, fileCopy).call(wd)
assert(result.out.trim() == "hellohello")
os.remove.all(wd)
assert(os.exists(wd) == false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment