feat: Working on configuration client

This commit is contained in:
2024-12-23 11:57:48 -05:00
parent d716348088
commit c07a0ef13b
7 changed files with 339 additions and 41 deletions

View File

@@ -2,10 +2,27 @@ import Dependencies
import FileClient
import Foundation
/// Represents a configuration file type and location.
public enum ConfigruationFile: Equatable, Sendable {
/// A json configuration file.
case json(URL)
/// A toml configuration file.
case toml(URL)
/// Default configuration file, which is a toml file
/// with the name of '.bump-version.toml'
public static var `default`: Self {
.toml(URL(
filePath: "\(ConfigurationClient.Constants.defaultFileNameWithoutExtension).toml"
))
}
/// Create a new file location from the given url.
///
/// - Parameters:
/// - url: The url for the file.
public init?(url: URL) {
if url.pathExtension == "toml" {
self = .toml(url)
@@ -16,6 +33,7 @@ public enum ConfigruationFile: Equatable, Sendable {
}
}
/// The url of the file.
var url: URL {
switch self {
case let .json(url): return url