Documented the AppArguments protocol and the Environment+Properties extension in the library target.

This commit is contained in:
Javier Cicchelli 2025-03-09 00:11:49 +01:00
parent 980c8e15f6
commit ab4a9207c5
4 changed files with 12 additions and 7 deletions

View File

@ -11,10 +11,10 @@ extension App {
var hostname: String = "127.0.0.1" var hostname: String = "127.0.0.1"
@Option(name: .shortAndLong) @Option(name: .shortAndLong)
var port: Int = 8080 var logLevel: Logger.Level?
@Option(name: .shortAndLong) @Option(name: .shortAndLong)
var logLevel: Logger.Level? var port: Int = 8080
} }
} }

View File

@ -4,6 +4,7 @@ extension Environment {
// MARK: Computed // MARK: Computed
/// The logging level set in the environment variables.
public var logLevel: String? { public var logLevel: String? {
self.get("LOG_LEVEL") self.get("LOG_LEVEL")
} }

View File

@ -1,11 +1,15 @@
import Logging import Logging
/// A type that defines the input arguments that the `Hummingbird`app receives.
public protocol AppArguments { public protocol AppArguments {
// MARK: Properties // MARK: Properties
/// A bind address for the app.
var hostname: String { get } var hostname: String { get }
/// A logging level to configure for the app.
var logLevel: Logger.Level? { get } var logLevel: Logger.Level? { get }
/// A port for the app to use,
var port: Int { get } var port: Int { get }
} }

View File

@ -6,7 +6,7 @@ struct TestArguments: AppArguments {
// MARK: Properties // MARK: Properties
let hostname = "127.0.0.1" let hostname = "127.0.0.1"
let port = 0
let logLevel: Logger.Level? = .trace let logLevel: Logger.Level? = .trace
let port = 0
} }