-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add ArgumentParser (#16) * Add ArgumentParser dependency * Rename SwiftPolyglotCore struct * Add RuntimeError * Rename SwiftPolyglot struct, add ParsableCommand adoption and add RuntimeError usage * Parse arguments and flag using ArgumentParser and adjust SwiftPolyglotCore initializer's parameters * Update README * Rename property * Format * Fix command name in help's message * Add Concurrency (#17) * Set minimum macOS version to version 10.15 (Catalina) * Add MissingTranslation struct * Add concurrency to core functionality * Adopt AsyncParsableCommand protocol to provide an asynchronous entry point * Add XCTest extension for testing async throwing expressions * Add concurrency to tests * Fix SwiftFormat issues (#19) * Remove trailing commas * Fix indentation * Move inline try to start of expression * Remove trailing white spaces * Use opaque generic parameters instead of generic parameters with constraints * Replace consecutive blank lines with a single blank line * Disable hoistAwait (#20) * Fix swiftformat (#21) * Improve assertions on async throwing expressions (#22) * Add Equatable adoption for custom error * Improve custom method for asserting on asynchronous expressions which should run successfully without throwing an error * Improve custom method for asserting on asynchronous expressions which should throw an error * Reenable hoistAwait SwiftFormat rule --------- Co-authored-by: Pere Bohigas <[email protected]>
- Loading branch information
1 parent
818d73f
commit 2d5751c
Showing
13 changed files
with
412 additions
and
243 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 |
---|---|---|
|
@@ -11,4 +11,5 @@ | |
|
||
# rules | ||
|
||
--disable preferForLoop | ||
--disable preferForLoop | ||
|
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,14 @@ | ||
{ | ||
"pins" : [ | ||
{ | ||
"identity" : "swift-argument-parser", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-argument-parser.git", | ||
"state" : { | ||
"revision" : "46989693916f56d1186bd59ac15124caef896560", | ||
"version" : "1.3.1" | ||
} | ||
} | ||
], | ||
"version" : 2 | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
enum RuntimeError: Error { | ||
case coreError(description: String) | ||
case fileListingNotPossible | ||
} | ||
|
||
extension RuntimeError: CustomStringConvertible { | ||
var description: String { | ||
switch self { | ||
case let .coreError(description): | ||
return description | ||
case .fileListingNotPossible: | ||
return "It was not possible to list all files to be checked" | ||
} | ||
} | ||
} |
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,36 @@ | ||
import ArgumentParser | ||
import Foundation | ||
import SwiftPolyglotCore | ||
|
||
@main | ||
struct SwiftPolyglot: AsyncParsableCommand { | ||
static let configuration: CommandConfiguration = .init(commandName: "swiftpolyglot") | ||
|
||
@Flag(help: "Log errors instead of warnings for missing translations.") | ||
private var errorOnMissing = false | ||
|
||
@Argument(help: "Specify the language(s) to be checked.") | ||
private var languages: [String] | ||
|
||
func run() async throws { | ||
guard | ||
let enumerator = FileManager.default.enumerator(atPath: FileManager.default.currentDirectoryPath), | ||
let filePaths = enumerator.allObjects as? [String] | ||
else { | ||
throw RuntimeError.fileListingNotPossible | ||
} | ||
|
||
let swiftPolyglotCore: SwiftPolyglotCore = .init( | ||
filePaths: filePaths, | ||
languageCodes: languages, | ||
logsErrorOnMissingTranslation: errorOnMissing, | ||
isRunningInAGitHubAction: ProcessInfo.processInfo.environment["GITHUB_ACTIONS"] == "true" | ||
) | ||
|
||
do { | ||
try await swiftPolyglotCore.run() | ||
} catch { | ||
throw RuntimeError.coreError(description: error.localizedDescription) | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,30 @@ | ||
struct MissingTranslation { | ||
enum Category { | ||
case deviceMissingOrNotTranslated(forDevice: String, inLanguage: String) | ||
case missingOrNotTranslated(inLanguage: String) | ||
case missingTranslation(forLanguage: String) | ||
case missingTranslationForAllLanguages | ||
case pluralMissingOrNotTranslated(forPluralForm: String, inLanguage: String) | ||
} | ||
|
||
let category: Category | ||
let filePath: String | ||
let originalString: String | ||
} | ||
|
||
extension MissingTranslation { | ||
var message: String { | ||
switch category { | ||
case let .deviceMissingOrNotTranslated(device, language): | ||
return "'\(originalString)' device '\(device)' is missing or not translated in '\(language)' in file: \(filePath)" | ||
case let .missingOrNotTranslated(language): | ||
return "'\(originalString)' is missing or not translated in '\(language)' in file: \(filePath)" | ||
case let .missingTranslation(language): | ||
return "'\(originalString)' is missing translations for language '\(language)' in file: \(filePath)" | ||
case .missingTranslationForAllLanguages: | ||
return "'\(originalString)' is not translated in any language in file: \(filePath)" | ||
case let .pluralMissingOrNotTranslated(pluralForm, language): | ||
return "'\(originalString)' plural form '\(pluralForm)' is missing or not translated in '\(language)' in file: \(filePath)" | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.