34 lines
1.0 KiB
Swift
34 lines
1.0 KiB
Swift
/// Represents keys in the environment that can be used to locate a user's
|
|
/// configuration file.
|
|
@_spi(Internal)
|
|
public enum EnvironmentKey {
|
|
static let xdgConfigHome = "XDG_CONFIG_HOME"
|
|
static let hpaConfigHome = "HPA_CONFIG_HOME"
|
|
static let hpaConfigFile = "HPA_CONFIG_FILE"
|
|
}
|
|
|
|
/// Represents keys that are used internally for directory names, file names, etc.
|
|
@_spi(Internal)
|
|
public enum HPAKey {
|
|
public static let configDirName = "hpa"
|
|
public static let resourceFileName = "hpa"
|
|
public static let resourceFileExtension = "toml"
|
|
public static let defaultFileName = "config.toml"
|
|
public static let defaultFileNameWithoutExtension = "config"
|
|
public static let tomlConfigUrl = "https://git.housh.dev/michael/swift-hpa/raw/branch/main/Sources/ConfigurationClient/Resources/hpa.toml"
|
|
}
|
|
|
|
extension [String: String] {
|
|
var xdgConfigHome: String {
|
|
self[EnvironmentKey.xdgConfigHome] ?? "~/.config"
|
|
}
|
|
|
|
var hpaConfigHome: String? {
|
|
self[EnvironmentKey.hpaConfigHome]
|
|
}
|
|
|
|
var hpaConfigFile: String? {
|
|
self[EnvironmentKey.hpaConfigFile]
|
|
}
|
|
}
|