diff --git a/Sources/phbar/CLI/cli+refresh.swift b/Sources/phbar/Commands/PHBar+Refresh.swift similarity index 80% rename from Sources/phbar/CLI/cli+refresh.swift rename to Sources/phbar/Commands/PHBar+Refresh.swift index 3c38516..996c1eb 100644 --- a/Sources/phbar/CLI/cli+refresh.swift +++ b/Sources/phbar/Commands/PHBar+Refresh.swift @@ -1,7 +1,7 @@ import ArgumentParser -extension phbar { - struct refresh: ParsableCommand { +extension PHBar { + struct Refresh: ParsableCommand { static let configuration = CommandConfiguration( commandName: "refresh", abstract: "Refresh the running status bar." diff --git a/Sources/phbar/CLI/cli+start.swift b/Sources/phbar/Commands/PHBar+Start.swift similarity index 95% rename from Sources/phbar/CLI/cli+start.swift rename to Sources/phbar/Commands/PHBar+Start.swift index 1f98b0a..13208ad 100644 --- a/Sources/phbar/CLI/cli+start.swift +++ b/Sources/phbar/Commands/PHBar+Start.swift @@ -2,8 +2,8 @@ import AppKit import ArgumentParser import Foundation -extension phbar { - struct start: ParsableCommand { +extension PHBar { + struct Start: ParsableCommand { static let configuration = CommandConfiguration( commandName: "start", abstract: "Start the status bar.", diff --git a/Sources/phbar/Models/PHBlock/PHBlock+Loading.swift b/Sources/phbar/Models/PHBlock/PHBlock+Loading.swift index ba65557..8e726d9 100644 --- a/Sources/phbar/Models/PHBlock/PHBlock+Loading.swift +++ b/Sources/phbar/Models/PHBlock/PHBlock+Loading.swift @@ -19,7 +19,7 @@ extension PHBlock { let setFile = base.appending(path: "blocks").appending(path: "\(blocks).toml") guard FileManager.default.fileExists(atPath: setFile.relativePath) else { - throw phbar.Error("Failed to load blocks '\(blocks)'") + throw PHBar.Error("Failed to load blocks '\(blocks)'") } return try load(from: setFile) } @@ -30,11 +30,11 @@ extension PHBlock { do { let data = try Data(contentsOf: url) guard let contents = String(data: data, encoding: .utf8), !contents.isEmpty else { - throw phbar.Error("the file is empty") + throw PHBar.Error("the file is empty") } return try load(from: contents) } catch { - throw phbar.Error("Failed to load blocks file", underlyingError: error) + throw PHBar.Error("Failed to load blocks file", underlyingError: error) } } @@ -46,7 +46,7 @@ extension PHBlock { let wrapper = try decoder.decode(PHBlock.Wrapper.self, from: contents) return wrapper.blocks } catch { - throw phbar.Error("Failed to parse blocks file", underlyingError: error) + throw PHBar.Error("Failed to parse blocks file", underlyingError: error) } } } diff --git a/Sources/phbar/Models/PHConfig/PHConfig+Loading.swift b/Sources/phbar/Models/PHConfig/PHConfig+Loading.swift index ea7c61e..393c1f9 100644 --- a/Sources/phbar/Models/PHConfig/PHConfig+Loading.swift +++ b/Sources/phbar/Models/PHConfig/PHConfig+Loading.swift @@ -24,7 +24,7 @@ extension PHConfig { withExtension: "toml" )?.resolvingSymlinksInPath() else { - throw phbar.Error("Failed to load config file") + throw PHBar.Error("Failed to load config file") } return try load(from: defaultConfig) } @@ -35,7 +35,7 @@ extension PHConfig { guard let data = try? Data(contentsOf: url), let contents = String(data: data, encoding: .utf8) else { - throw phbar.Error("Failed to load config file") + throw PHBar.Error("Failed to load config file") } return try load(from: contents) @@ -53,7 +53,7 @@ extension PHConfig { // resolve the same set. return config.resolvingEnv() } catch { - throw phbar.Error("Failed to parse config file", underlyingError: error) + throw PHBar.Error("Failed to parse config file", underlyingError: error) } } } diff --git a/Sources/phbar/Models/PHTheme/PHTheme+Loading.swift b/Sources/phbar/Models/PHTheme/PHTheme+Loading.swift index 2898765..19184ef 100644 --- a/Sources/phbar/Models/PHTheme/PHTheme+Loading.swift +++ b/Sources/phbar/Models/PHTheme/PHTheme+Loading.swift @@ -28,7 +28,7 @@ extension PHTheme { withExtension: "toml" )?.resolvingSymlinksInPath() else { - throw phbar.Error("Failed to load theme file") + throw PHBar.Error("Failed to load theme file") } return try load(from: defaultConfig, environment: .process) } @@ -39,11 +39,11 @@ extension PHTheme { do { let data = try Data(contentsOf: url) guard let contents = String(data: data, encoding: .utf8), !contents.isEmpty else { - throw phbar.Error("the file is empty") + throw PHBar.Error("the file is empty") } return try load(from: contents, environment: environment) } catch { - throw phbar.Error("Failed to load theme file", underlyingError: error) + throw PHBar.Error("Failed to load theme file", underlyingError: error) } } @@ -55,7 +55,7 @@ extension PHTheme { decoder.userInfo[PHEnvironment.userInfoKey] = environment return try decoder.decode(PHTheme.self, from: contents) } catch { - throw phbar.Error("Failed to parse theme file", underlyingError: error) + throw PHBar.Error("Failed to parse theme file", underlyingError: error) } } } diff --git a/Sources/phbar/cli.swift b/Sources/phbar/PHBar.swift similarity index 97% rename from Sources/phbar/cli.swift rename to Sources/phbar/PHBar.swift index 4cc50bd..cadcebd 100644 --- a/Sources/phbar/cli.swift +++ b/Sources/phbar/PHBar.swift @@ -8,7 +8,7 @@ import ArgumentParser import Foundation @main -struct phbar: ParsableCommand { +struct PHBar: ParsableCommand { static let configuration = CommandConfiguration( commandName: "phbar", abstract: "Modular status bar for macOS.", @@ -39,11 +39,11 @@ struct phbar: ParsableCommand { the same command to start the bar automatically at login. """, version: "1.0.0", - subcommands: [start.self, refresh.self] + subcommands: [Start.self, Refresh.self] ) } -extension phbar { +extension PHBar { struct Error: LocalizedError { let message: String let underlyingError: Swift.Error? diff --git a/Tests/phbarTests/BarControllerTests.swift b/Tests/phbarTests/BarControllerTests.swift index 0232c28..5973762 100644 --- a/Tests/phbarTests/BarControllerTests.swift +++ b/Tests/phbarTests/BarControllerTests.swift @@ -7,7 +7,7 @@ import Testing // MARK: - Refresh command @Test func refreshCommandConfigurationIsCorrect() async throws { - let config = phbar.refresh.configuration + let config = PHBar.Refresh.configuration #expect(config.commandName == "refresh") #expect(config.abstract == "Refresh the running status bar.") }