refactor: rename HOST_* env vars to SLHAF_HUB_* across CLI/TUI, security, docs, and compose

This commit is contained in:
2026-02-25 13:59:27 +08:00
parent ff012c3b9a
commit 757af8d89b
6 changed files with 20 additions and 20 deletions

View File

@@ -9,8 +9,8 @@ import java.net.http.HttpResponse
import java.nio.charset.StandardCharsets
import kotlin.system.exitProcess
val ENV_API_BASE_URL = "HOST_API_BASE_URL"
val ENV_API_TOKEN = "HOST_API_TOKEN"
val ENV_API_BASE_URL = "SLHAF_HUB_BASE_URL"
val ENV_API_TOKEN = "SLHAF_HUB_TOKEN"
data class GlobalOptions(
val baseUrl: String,
@@ -30,9 +30,9 @@ Usage:
kotlin slhaf-hub-cli.kts [global options] <command> [command options]
Global options:
--base-url=<url> Default: HOST_API_BASE_URL or http://127.0.0.1:8080
--base-url=<url> Default: SLHAF_HUB_BASE_URL or http://127.0.0.1:8080
--token=<token> Authorization token
--token-file=<path> Load token from file (fallback: HOST_API_TOKEN env)
--token-file=<path> Load token from file (fallback: SLHAF_HUB_TOKEN env)
Commands:
health

View File

@@ -54,8 +54,8 @@ private val YELLOW = "\u001b[33m"
private val RED = "\u001b[31m"
private val BG_BLUE = "\u001b[44m"
private val FG_BLACK = "\u001b[30m"
val ENV_API_BASE_URL = "HOST_API_BASE_URL"
val ENV_API_TOKEN = "HOST_API_TOKEN"
val ENV_API_BASE_URL = "SLHAF_HUB_BASE_URL"
val ENV_API_TOKEN = "SLHAF_HUB_TOKEN"
private fun ok(text: String) = "$GREEN$text$RESET"
private fun warn(text: String) = "$YELLOW$text$RESET"
@@ -81,8 +81,8 @@ Keys:
q Quit
Env fallback:
HOST_API_BASE_URL
HOST_API_TOKEN
SLHAF_HUB_BASE_URL
SLHAF_HUB_TOKEN
""".trimIndent()
fun parseOptions(args: List<String>): Options {
@@ -113,7 +113,7 @@ fun readToken(options: Options): String {
return file.readText().trim()
}
return System.getenv(ENV_API_TOKEN)?.trim()
?: error("Missing token. Use --token or --token-file or HOST_API_TOKEN")
?: error("Missing token. Use --token or --token-file or SLHAF_HUB_TOKEN")
}
fun encode(value: String): String = URLEncoder.encode(value, StandardCharsets.UTF_8)