Skip to content

Commit 4c07125

Browse files
authored
Remove Never return from ParsableCommand.main() (#162)
This provides support for using the `@main` attribute on the root command type.
1 parent 8883f06 commit 4c07125

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Sources/ArgumentParser/Parsable Types/ParsableCommand.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,24 @@ extension ParsableCommand {
8484
}
8585

8686
/// Parses an instance of this type, or one of its subcommands, from
87-
/// command-line arguments and calls its `run()` method, exiting cleanly
88-
/// or with a relevant error message.
87+
/// the given arguments and calls its `run()` method, exiting with a
88+
/// relevant error message if necessary.
8989
///
9090
/// - Parameter arguments: An array of arguments to use for parsing. If
9191
/// `arguments` is `nil`, this uses the program's command-line arguments.
92-
public static func main(_ arguments: [String]? = nil) -> Never {
92+
public static func main(_ arguments: [String]?) {
9393
do {
9494
let command = try parseAsRoot(arguments)
9595
try command.run()
96-
exit()
9796
} catch {
9897
exit(withError: error)
9998
}
10099
}
100+
101+
/// Parses an instance of this type, or one of its subcommands, from
102+
/// command-line arguments and calls its `run()` method, exiting with a
103+
/// relevant error message if necessary.
104+
public static func main() {
105+
self.main(nil)
106+
}
101107
}

0 commit comments

Comments
 (0)