From 92a9c6b320d5dde5699ef0778e411209688f20be Mon Sep 17 00:00:00 2001 From: George Barnett Date: Mon, 24 Oct 2022 09:33:31 +0100 Subject: [PATCH] Fix HelloWorld examples (#1512) Resolves #1511 --- .../Client/{main.swift => HelloWorldClient.swift} | 8 ++++++++ .../Server/{main.swift => HelloWorldServer.swift} | 8 ++++++++ 2 files changed, 16 insertions(+) rename Sources/Examples/HelloWorld/Client/{main.swift => HelloWorldClient.swift} (94%) rename Sources/Examples/HelloWorld/Server/{main.swift => HelloWorldServer.swift} (92%) diff --git a/Sources/Examples/HelloWorld/Client/main.swift b/Sources/Examples/HelloWorld/Client/HelloWorldClient.swift similarity index 94% rename from Sources/Examples/HelloWorld/Client/main.swift rename to Sources/Examples/HelloWorld/Client/HelloWorldClient.swift index 0849f7c66..41de5df33 100644 --- a/Sources/Examples/HelloWorld/Client/main.swift +++ b/Sources/Examples/HelloWorld/Client/HelloWorldClient.swift @@ -21,6 +21,7 @@ import NIOCore import NIOPosix @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +@main struct HelloWorld: AsyncParsableCommand { @Option(help: "The port to connect to") var port: Int = 1234 @@ -67,4 +68,11 @@ struct HelloWorld: AsyncParsableCommand { } } } +#else +@main +enum HelloWorld { + static func main() { + fatalError("This example requires swift >= 5.6") + } +} #endif // compiler(>=5.6) diff --git a/Sources/Examples/HelloWorld/Server/main.swift b/Sources/Examples/HelloWorld/Server/HelloWorldServer.swift similarity index 92% rename from Sources/Examples/HelloWorld/Server/main.swift rename to Sources/Examples/HelloWorld/Server/HelloWorldServer.swift index 9b22dfdc6..aa78f86f0 100644 --- a/Sources/Examples/HelloWorld/Server/main.swift +++ b/Sources/Examples/HelloWorld/Server/HelloWorldServer.swift @@ -21,6 +21,7 @@ import NIOCore import NIOPosix @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +@main struct HelloWorld: AsyncParsableCommand { @Option(help: "The port to listen on for new connections") var port = 1234 @@ -43,4 +44,11 @@ struct HelloWorld: AsyncParsableCommand { try await server.onClose.get() } } +#else +@main +enum HelloWorld { + static func main() { + fatalError("This example requires swift >= 5.6") + } +} #endif // compiler(>=5.6)