Files
swift-hpa/Sources/ConfigurationClient/Constants.swift
Michael Housh faa28749bc
All checks were successful
CI / Run Tests (push) Successful in 2m43s
feat: Merges dev
2024-12-17 15:55:36 -05:00

33 lines
933 B
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"
}
extension [String: String] {
var xdgConfigHome: String {
self[EnvironmentKey.xdgConfigHome] ?? "~/.config"
}
var hpaConfigHome: String? {
self[EnvironmentKey.hpaConfigHome]
}
var hpaConfigFile: String? {
self[EnvironmentKey.hpaConfigFile]
}
}