-
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 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
- Loading branch information
1 parent
818d73f
commit 59968c2
Showing
9 changed files
with
116 additions
and
76 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,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: ParsableCommand { | ||
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() 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 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
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