Skip to content

Commit

Permalink
feat: add project aliases to cfg command
Browse files Browse the repository at this point in the history
  • Loading branch information
SettingDust committed Oct 6, 2024
1 parent fd23de2 commit b2bf4e0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/commonMain/kotlin/teksturepako/pakku/cli/cmd/Cfg.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.core.subcommands
import com.github.ajalt.clikt.core.terminal
import com.github.ajalt.clikt.parameters.options.associate
import com.github.ajalt.clikt.parameters.options.help
import com.github.ajalt.clikt.parameters.options.option
import kotlinx.coroutines.runBlocking
Expand Down Expand Up @@ -56,6 +57,12 @@ class Cfg : CliktCommand()
private val shadersPathOpt by option("--shaders-path", metavar = "path")
.help("Change the path for the `${ProjectType.SHADER}` project type")

private val projectAliasesOpts: Map<String, String>? by option(
"-pa", "--project-alias",
help = "Add alias for project",
metavar = "<alias>=<project>"
).associate()

override fun run(): Unit = runBlocking {

val configFile = ConfigFile.readOrNew()
Expand Down Expand Up @@ -128,6 +135,15 @@ class Cfg : CliktCommand()
echo()
}

projectAliasesOpts?.let { opt ->
for ((alias, project) in opt)
{
configFile.projectAliases[alias] = project
terminal.pSuccess("'project_aliases.$alias' set to '$project'.")
echo()
}
}

configFile.write()?.let {
terminal.pError(it)
echo()
Expand Down

0 comments on commit b2bf4e0

Please sign in to comment.