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

com.github.leandroborgesferreira.dagcommand.adapter.AdapterFunctions.kt Maven / Gradle / Ivy

There is a newer version: 1.7.0
Show newest version
package com.github.leandroborgesferreira.dagcommand.adapter

import com.github.leandroborgesferreira.dagcommand.domain.Config
import com.github.leandroborgesferreira.dagcommand.enums.ModuleType
import com.github.leandroborgesferreira.dagcommand.enums.OutputType
import com.github.leandroborgesferreira.dagcommand.extension.CommandExtension

fun CommandExtension.parse(): Config =
    Config(
        filter = findFilter(filter),
        defaultBranch = defaultBranch,
        outputType = findOutputType(outputType),
        outputPath = outputPath,
        printAdjacencyList = printAdjacencyList,
        printEdgesList = printEdgesList,
        printBuildStages = printBuildStages
    )

private fun findFilter(filter: String): ModuleType =
    ModuleType
        .values()
        .find { enum -> enum.value.equals(filter, ignoreCase = true) }
        ?: throw IllegalStateException("This type of filter: $filter. Is not supported.")

private fun findOutputType(outputType: String): OutputType =
    OutputType
        .values()
        .find { enum -> enum.value.equals(outputType, ignoreCase = true) }
        ?: throw IllegalStateException("This type of output: $outputType. Is not supported.")




© 2015 - 2025 Weber Informatics LLC | Privacy Policy