All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.core.MkTemp.kt Maven / Gradle / Ivy

There is a newer version: 0.0.87
Show newest version
package pl.mareklangiewicz.kommand.core

import kotlinx.coroutines.flow.*
import pl.mareklangiewicz.annotations.DelicateApi
import pl.mareklangiewicz.kommand.*

@OptIn(DelicateApi::class)
fun mktemp(
  vararg useNamedArgs: Unit,
  path: String = ".",
  prefix: String = "tmp.",
  suffix: String = ".tmp",
) = mktemp("$path/${prefix}XXXXXX${suffix}").reducedOut { single() }

@DelicateApi
fun mktemp(template: String, init: MkTemp.() -> Unit = {}) = mktemp { +template; init() }

@DelicateApi
fun mktemp(init: MkTemp.() -> Unit) = MkTemp().apply(init)

@DelicateApi
data class MkTemp(
  override val opts: MutableList = mutableListOf(),
  override val nonopts: MutableList = mutableListOf(),
) : KommandTypical {
  override val name get() = "mktemp"
}

@DelicateApi
interface MkTempOpt : KOptTypical {
  data object Directory : KOptS("d"), MkTempOpt
  data object DryRun : KOptS("u"), MkTempOpt
  data object Quiet : KOptS("q"), MkTempOpt
  data class Suffix(val suffix: String) : KOptLN(suffix), MkTempOpt
  data class TmpDir(val dir: String? = null) : KOptS("p", dir), MkTempOpt
  data object Help : KOptLN(), MkTempOpt
  data object Version : KOptLN(), MkTempOpt
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy