forked from majd/ipatool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
238 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// AsyncSupport.swift | ||
// IPATool | ||
// | ||
// Created by Majd Alfhaily on 04.01.22. | ||
// | ||
|
||
import Foundation | ||
import ArgumentParser | ||
|
||
protocol AsyncParsableCommand: ParsableCommand { | ||
mutating func run() async throws | ||
} | ||
|
||
extension AsyncParsableCommand { | ||
mutating func run() throws { | ||
throw CleanExit.helpRequest(self) | ||
} | ||
} | ||
|
||
protocol AsyncMain { | ||
associatedtype Command: ParsableCommand | ||
} | ||
|
||
extension AsyncMain { | ||
static func main() async { | ||
do { | ||
var command = try Command.parseAsRoot() | ||
if var command = command as? AsyncParsableCommand { | ||
try await command.run() | ||
} else { | ||
try command.run() | ||
} | ||
} catch { | ||
Command.exit(withError: error) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.