Package-level declarations

Types

Link copied to clipboard
sealed interface CleanRefusal

Reason why cleaning a directory is refused for safety. Combined with --clean, accidental targeting of a sensitive directory could result in irreversible data loss, so the CLI refuses any of these cases up front.

Link copied to clipboard

Simple immutable stopwatch to measure elapsed time in milliseconds.

Functions

Link copied to clipboard
fun File.checkCleanSafety(sourceFile: File?, homeDirectory: File? = systemDirectory("user.home"), workingDirectory: File? = systemDirectory("user.dir")): CleanRefusal?

Decides whether this directory can be safely wiped by the CLI --clean flag.

Link copied to clipboard

Cleans this directory by deleting all files and directories inside it. Does nothing if the directory is empty or if the file does not exist or is not a directory.

Link copied to clipboard
fun <T : Any> NullableOption<T, T>.promptOrDefault(text: String, default: String = ""): OptionWithValues<T, T, T>

Like Clikt's prompt, but a closed input, such as a non-interactive shell or a pipe at its end, yields default instead of failing with a missing-option error.

Link copied to clipboard
fun <T : Any> NullableOption<T, T>.promptUnless(text: String, default: String, fallback: () -> T?): OptionWithValues<T, T, T>

Like Clikt's prompt, but the prompt is skipped when fallback yields a value, which is then used as if the user had passed it. Resolution order: the value given on the command line, then fallback, then the interactive prompt. The typed answer, as well as default, goes through the option's own conversion, so validation and error messages match the command-line form; an invalid answer is asked again. A closed input yields default. Like Clikt's prompt, no prompt is shown once another parameter has already failed.

Link copied to clipboard
fun <T> runWithTimeout(timeoutSeconds: Int?, onTimeout: (ExecutionTimeoutException) -> T? = null, action: () -> T): T

Runs action with an optional timeout. If timeoutSeconds is null or non-positive, action is executed directly on the current thread. Otherwise, it is submitted and bounded by the given duration.