Fork channel

Create a new channel as a copy of main.

Rename channel

Rename main to:

Delete channel

Delete main? This cannot be undone.

Filename.kt
package com.github.jonathanxd.dracon.log

import com.github.jonathanxd.dracon.cmd.removeTrailingSlash

@JvmInline
value class Filename(val name: String)

@JvmInline
value class FileDir(val dir: String)

@JvmInline
value class FilePath(val fullPath: String)

//\"src/test/kotlin/com/github/jonathanxd/dracon/test/DraconTest.kt\"
fun String.parseFilePath(): FilePath = FilePath(this.unescape())
fun String.parseFilename(): Filename = Filename(this.unescape())
fun String.parseFileDir(): FileDir = FileDir(this.unescape())

operator fun FileDir.plus(name: Filename) =
    FilePath(this.dir.resolve(name.name))

operator fun FileDir.plus(name: FilePath) =
    FilePath(this.dir.resolve(name.fullPath))

operator fun FilePath.plus(name: FilePath) =
    FilePath(this.fullPath.resolve(name.fullPath))

fun String.resolve(other: String) =
    "${this.removePathTrailingSlash()}/${other.removePathLeadingSlash()}"


const val ESCAPED_STRING_PREFIX = """\""""
fun String.unescape(): String =
    if (this.startsWith(ESCAPED_STRING_PREFIX) && this.endsWith(ESCAPED_STRING_PREFIX))
        this.substring(ESCAPED_STRING_PREFIX.length, this.length - ESCAPED_STRING_PREFIX.length)
    else this

private fun String.removePathTrailingSlash() =
    if (this.endsWith("/")) this.substring(0, this.lastIndex)
    else this

private fun String.removePathLeadingSlash() =
    if (this.startsWith("/")) this.substring(1, this.length)
    else this