Skip to content

Commit

Permalink
Update format
Browse files Browse the repository at this point in the history
  • Loading branch information
mackoj committed Dec 14, 2019
1 parent 6099706 commit 6662ce2
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ elif ! [ -x "$(command -v swift-format)" ]; then
ln -s /Applications/Xcode.app/Contents/Developer/usr/bin/generate-pipeline /usr/local/bin/generate-pipeline
else
echo "Linting..."
git diff --diff-filter=d --cached --name-only | grep -E '\.(swift)$' | xargs -I{} swift-format -m lint --configuration .swift-format -i {}
git diff --diff-filter=d --cached --name-only | grep -E '\.(swift)$' | xargs -I{} swift-format -m lint --configuration .swift-format {}
echo "Auto-Formatting..."
git diff --diff-filter=d --cached --name-only | grep -E '\.(swift)$' | xargs -I{} swift-format -m format -r --configuration .swift-format -i {}
fi
Expand Down
2 changes: 1 addition & 1 deletion .swift-format
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"AlwaysUseLowerCamelCase" : true,
"AmbiguousTrailingClosureOverload" : true,
"BeginDocumentationCommentWithOneLineSummary" : true,
"BlankLineBetweenMembers" : true,
"BlankLineBetweenMembers" : false,
"CaseIndentLevelEqualsSwitch" : true,
"DoNotUseSemicolons" : true,
"DontRepeatTypeInStaticProperties" : true,
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@
This package help to find/filter/sort all devices and runtimes available in xcrun simctl.

```swift
#!/usr/bin/swift sh

import Foundation
import PlatformLookup // @mackoj

func findDevicePlatform(_ args: [String]) throws {
if let platform: String = try PlatformLookup.findADeviceForLastOSVersion() {
// Expecting: iOS Simulator,name=iPhone 11 Pro Max,OS=13.2
print(platform)
} else {
print("👉 Failure 💩")
exit(EXIT_FAILURE)
}
}

do {
try findDevicePlatform(CommandLine.arguments)
} catch {
print(error.localizedDescription)
exit(EXIT_FAILURE)
}
```

# SimulatorControl 📲
Expand Down
16 changes: 16 additions & 0 deletions Sources/PlatformLookup/PlatformLookup+Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ extension PlatformLookup {
case failedToInitializeDataIsNotValid
case unknowDeviceFamilly(String)
case noRuntimeFound
/// A localized message describing what error occurred.
public var errorDescription: String? {
switch self {
case .failedToInitializeDataIsNotValid:
Expand All @@ -18,5 +19,20 @@ extension PlatformLookup {
case .noRuntimeFound: return NSLocalizedString("Runtime unknown", comment: "Unknown Runtime")
}
}
/// A localized message describing the reason for the failure.
public var failureReason: String? {
return "failureReason" // switch self {
// case .failedToInitializeDataIsNotValid:
// <#code#>
// case .unknowDeviceFamilly(_):
// <#code#>
// case .noRuntimeFound:
// <#code#>
// }
}
/// A localized message describing how one might recover from the failure.
public var recoverySuggestion: String? { return "failureReason" }
/// A localized message providing "help" text if the user requests help.
public var helpAnchor: String? { return "failureReason" }
}
}
2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## P0
- [ ] Add missing tests
- [ ] Remove all the warnings
- [ ] Add simple script to call them

## P1
- [ ] Code Documentation
Expand All @@ -14,3 +15,4 @@
- [ ] PR Boiler plate
- [ ] Auto review
- [ ] Dr String
- [ ] How to help translate error message
18 changes: 18 additions & 0 deletions findDevicePlatform.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Foundation
// import PlatformLookup // mackoj/SimulatorControl ~> 0.8.0
import PlatformLookup // https://github.com/mackoj/SimulatorControl == a037a15

func findDevicePlatform(_ args: [String]) throws {
if let platform:String = try PlatformLookup.findADeviceForLastOSVersion() {
// Expecting: iOS Simulator,name=iPhone 11 Pro Max,OS=13.2
print(platform)
} else {
print("👉 Failure 💩")
exit(EXIT_FAILURE)
}
}

do { try findDevicePlatform(CommandLine.arguments) } catch {
print(error.localizedDescription)
exit(EXIT_FAILURE)
}

0 comments on commit 6662ce2

Please sign in to comment.