feat: Working on hummingbird app
This commit is contained in:
29
Sources/HApp/App.swift
Normal file
29
Sources/HApp/App.swift
Normal 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
|
||||
Reference in New Issue
Block a user