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

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

View File

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

View File

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

View File

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