Skip to content

Instantly share code, notes, and snippets.

@jkinkead
Created November 1, 2017 21:07
Show Gist options
  • Save jkinkead/faac54c15b300d9adfdb56e70ff6ab69 to your computer and use it in GitHub Desktop.
Save jkinkead/faac54c15b300d9adfdb56e70ff6ab69 to your computer and use it in GitHub Desktop.
// Arguments for an execution of 'rm'. Now with sorted flags!
data class RmOptions(val path: String, val force: Boolean, val recursive: Boolean)
val options: RmOptions = getOptions()
// (oops)
val (path, recursive, force) = options
val args = ArrayList<String>()
if (recursive) {
args.append("-r")
}
if (force) {
args.append("-f")
}
args.append(path)
// Remove using the system.
Process = ProcessBuilder(args).start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment