feat: Working on hummingbird app

This commit is contained in:
2025-01-14 07:51:13 -05:00
parent 6225c32007
commit 4f47f1aed8
10 changed files with 223 additions and 86 deletions

29
Sources/HApp/App.swift Normal file
View File

@@ -0,0 +1,29 @@
import ArgumentParser
import Hummingbird
import Logging
@main
struct App: AsyncParsableCommand {
@Option(name: .shortAndLong)
var hostname: String = "127.0.0.1"
@Option(name: .shortAndLong)
var port: Int = 8080
@Option(name: .shortAndLong)
var logLevel: Logger.Level?
func run() async throws {
let app = try await buildApplication(.init(hostname: hostname, port: port, logLevel: logLevel))
try await app.runService()
}
}
/// Extend `Logger.Level` so it can be used as an argument
#if hasFeature(RetroactiveAttribute)
extension Logger.Level: @retroactive ExpressibleByArgument {}
#else
extension Logger.Level: ExpressibleByArgument {}
#endif