Skip to content

Commit 0bbc937

Browse files
committed
Examples: Adopt ArgumentParser
1 parent d10e652 commit 0bbc937

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

Examples/HelloWorldWithResources/Package.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ let package = Package(
2222
dependencies: [
2323
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.1.0"),
2424
.package(url: "https://github.com/apple/swift-container-plugin", from: "0.5.0"),
25+
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0"),
2526
],
2627
targets: [
2728
.executableTarget(
2829
name: "hello-world",
29-
dependencies: [.product(name: "Hummingbird", package: "hummingbird")],
30+
dependencies: [
31+
.product(name: "Hummingbird", package: "hummingbird"),
32+
.product(name: "ArgumentParser", package: "swift-argument-parser"),
33+
],
3034
resources: [.process("resources")]
3135
)
3236
]

Examples/HelloWorldWithResources/Sources/App.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
import ArgumentParser
16+
1517
@main
16-
struct Hello {
17-
static let hostname = "0.0.0.0"
18-
static let port = 8080
18+
struct Hello: AsyncParsableCommand {
19+
@Option(name: .shortAndLong)
20+
var hostname: String = "0.0.0.0"
21+
22+
@Option(name: .shortAndLong)
23+
var port: Int = 8080
1924

20-
static func main() async throws {
25+
func run() async throws {
2126
let app = buildApplication(
2227
configuration: .init(
2328
address: .hostname(hostname, port: port),

0 commit comments

Comments
 (0)