This file contains hidden or 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
| extension Tasks { | |
| struct Uninstall: ParsableCommand { | |
| static var configuration = CommandConfiguration( | |
| commandName: "uninstall", | |
| abstract: "Uninstall Uploader and remove from system." | |
| ) | |
| func run() throws { | |
| try runShell("rm -f /usr/local/bin/uploader") | |
| } |
This file contains hidden or 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
| extension Tasks { | |
| struct Install: ParsableCommand { | |
| static var configuration = CommandConfiguration( | |
| commandName: "install", | |
| abstract: "Install Uploader for running globally." | |
| ) | |
| func run() throws { | |
| try runShell("swift build -c release") | |
| try runShell("install .build/release/uploader-cli /usr/local/bin/uploader") |
This file contains hidden or 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
| extension Tasks { | |
| struct Linting: ParsableCommand { | |
| static var configuration = CommandConfiguration( | |
| commandName: "lint", | |
| abstract: "Lint the Uploader codebase, such as static analysis." | |
| ) | |
| func run() throws { | |
| try runShell("swift run swiftformat . --lint", continueOnError: true) | |
| try runShell("swift run swiftlint") |
This file contains hidden or 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
| func runShell(_ command: String, continueOnError: Bool = false) throws { | |
| do { | |
| try shellOut( | |
| to: command, | |
| outputHandle: .standardOutput, | |
| errorHandle: .standardError | |
| ) | |
| } catch { | |
| if !continueOnError { | |
| throw ShellError() |
This file contains hidden or 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
| struct Tasks: ParsableCommand { | |
| static let configuration = CommandConfiguration( | |
| commandName: "tasks", | |
| abstract: "An automation task runner for Uploader.", | |
| subcommands: [Linting.self, Install.self, Uninstall.self] | |
| ) | |
| } | |
| Tasks.main() |
This file contains hidden or 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
| products: [ | |
| ... | |
| .executable(name: "task", targets: ["UploaderTasks"]) | |
| ] |
This file contains hidden or 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
| targets: [ | |
| ... | |
| .target( | |
| name: "UploaderTasks", | |
| dependencies: ["ArgumentParser", "ShellOut"] | |
| ) | |
| ] |
This file contains hidden or 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
| let package = Package( | |
| name: "Uploader", | |
| products: [ | |
| .executable(name: "uploader-cli", targets: ["Uploader"]) | |
| ], | |
| dependencies: [ | |
| .package( | |
| url: "https://github.com/realm/SwiftLint", | |
| from: "0.39.1" | |
| ), |
This file contains hidden or 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
| class OrderDetailActivity : FragmentActivity() { | |
| val orderId by lazy { | |
| intent.getParcelableExtra<OrderId>(EXTRA_ORDER_ID) | |
| } | |
| } |
This file contains hidden or 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
| private val messageId by lazy(LazyThreadSafetyMode.NONE) { createMessageId() } |