Skip to content

Commit 74f1f8c

Browse files
authored
Simplify configuration check for async root command (#736)
If the synchronous `main()` is running for an `AsyncParsableCommand` root, something went wrong. Previously, this was only diagnosed when there was an async subcommand; this change expands the failure condition to include standalone async commands. Fixes #662.
1 parent f2eda39 commit 74f1f8c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Sources/ArgumentParser/Parsable Types/ParsableCommand.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,12 @@ extension ParsableCommand {
146146
/// - Parameter arguments: An array of arguments to use for parsing. If
147147
/// `arguments` is `nil`, this uses the program's command-line arguments.
148148
public static func main(_ arguments: [String]?) {
149-
150149
#if DEBUG
151150
if #available(macOS 10.15, macCatalyst 13, iOS 13, tvOS 13, watchOS 6, *) {
152-
if let asyncCommand = firstAsyncSubcommand(self) {
153-
if Self() is AsyncParsableCommand {
154-
failAsyncPlatform(rootCommand: self)
155-
} else {
156-
failAsyncHierarchy(rootCommand: self, subCommand: asyncCommand)
157-
}
151+
if Self() is AsyncParsableCommand {
152+
failAsyncPlatform(rootCommand: self)
153+
} else if let asyncCommand = firstAsyncSubcommand(self) {
154+
failAsyncHierarchy(rootCommand: self, subCommand: asyncCommand)
158155
}
159156
}
160157
#endif

0 commit comments

Comments
 (0)