Fix error/warning message to be shown in Xcode.IssueNavigator
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit

This commit is contained in:
Thibaut Schmitt 2022-11-22 17:14:13 +01:00
parent 5a3d273acc
commit fc427733ee
27 changed files with 79 additions and 79 deletions

View File

@ -77,21 +77,21 @@ struct Colors: ParsableCommand {
// Check if input file exists // Check if input file exists
guard fileManager.fileExists(atPath: options.inputFile) else { guard fileManager.fileExists(atPath: options.inputFile) else {
let error = ColorsToolError.fileNotExists(options.inputFile) let error = ColorsToolError.fileNotExists(options.inputFile)
print(error.localizedDescription) print(error.description)
Colors.exit(withError: error) Colors.exit(withError: error)
} }
// Check if xcassets file exists // Check if xcassets file exists
guard fileManager.fileExists(atPath: options.xcassetsPath) else { guard fileManager.fileExists(atPath: options.xcassetsPath) else {
let error = ColorsToolError.fileNotExists(options.xcassetsPath) let error = ColorsToolError.fileNotExists(options.xcassetsPath)
print(error.localizedDescription) print(error.description)
Colors.exit(withError: error) Colors.exit(withError: error)
} }
// Extension for UIKit and SwiftUI should have different name // Extension for UIKit and SwiftUI should have different name
guard options.extensionName != options.extensionNameSwiftUI else { guard options.extensionName != options.extensionNameSwiftUI else {
let error = ColorsToolError.extensionNamesCollision(options.extensionName) let error = ColorsToolError.extensionNamesCollision(options.extensionName)
print(error.localizedDescription) print(error.description)
Colors.exit(withError: error) Colors.exit(withError: error)
} }
@ -117,7 +117,7 @@ struct Colors: ParsableCommand {
try fileManager.removeItem(atPath: assetsColorPath) try fileManager.removeItem(atPath: assetsColorPath)
} catch { } catch {
let error = ColorsToolError.deleteExistingColors("\(options.xcassetsPath)/Colors") let error = ColorsToolError.deleteExistingColors("\(options.xcassetsPath)/Colors")
print(error.localizedDescription) print(error.description)
Colors.exit(withError: error) Colors.exit(withError: error)
} }
} }

View File

@ -20,28 +20,28 @@ enum ColorsToolError: Error {
var description: String { var description: String {
switch self { switch self {
case .extensionNamesCollision(let extensionName): case .extensionNamesCollision(let extensionName):
return "error:[\(Fonts.toolName)] Error on extension names, extension name and SwiftUI extension name should be different (\(extensionName) is used on both)" return "error: [\(Fonts.toolName)] Error on extension names, extension name and SwiftUI extension name should be different (\(extensionName) is used on both)"
case .badFormat(let info): case .badFormat(let info):
return "error:[\(Colors.toolName)] Bad line format: \(info). Accepted format are: colorName=\"#RGB/#ARGB\"; colorName \"#RGB/#ARGB\"; colorName \"#RGB/#ARGB\" \"#RGB/#ARGB\"" return "error: [\(Colors.toolName)] Bad line format: \(info). Accepted format are: colorName=\"#RGB/#ARGB\"; colorName \"#RGB/#ARGB\"; colorName \"#RGB/#ARGB\" \"#RGB/#ARGB\""
case .writeAsset(let info): case .writeAsset(let info):
return "error:[\(Colors.toolName)] An error occured while writing color in Xcasset: \(info)" return "error: [\(Colors.toolName)] An error occured while writing color in Xcasset: \(info)"
case .createAssetFolder(let assetsFolder): case .createAssetFolder(let assetsFolder):
return "error:[\(Colors.toolName)] An error occured while creating colors folder `\(assetsFolder)`" return "error: [\(Colors.toolName)] An error occured while creating colors folder `\(assetsFolder)`"
case .writeExtension(let filename, let info): case .writeExtension(let filename, let info):
return "error:[\(Colors.toolName)] An error occured while writing extension in \(filename): \(info)" return "error: [\(Colors.toolName)] An error occured while writing extension in \(filename): \(info)"
case .fileNotExists(let filename): case .fileNotExists(let filename):
return "error:[\(Colors.toolName)] File \(filename) does not exists" return "error: [\(Colors.toolName)] File \(filename) does not exists"
case .badColorDefinition(let lightColor, let darkColor): case .badColorDefinition(let lightColor, let darkColor):
return "error:[\(Colors.toolName)] One of these two colors has invalid synthax: -\(lightColor)- or -\(darkColor)-" return "error: [\(Colors.toolName)] One of these two colors has invalid synthax: -\(lightColor)- or -\(darkColor)-"
case .deleteExistingColors(let assetsFolder): case .deleteExistingColors(let assetsFolder):
return "error:[\(Colors.toolName)] An error occured while deleting colors folder `\(assetsFolder)`" return "error: [\(Colors.toolName)] An error occured while deleting colors folder `\(assetsFolder)`"
} }
} }
} }

View File

@ -32,7 +32,7 @@ struct ColorExtensionGenerator {
try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8) try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) { } catch (let error) {
let error = ColorsToolError.writeExtension(extensionFilePath, error.localizedDescription) let error = ColorsToolError.writeExtension(extensionFilePath, error.localizedDescription)
print(error.localizedDescription) print(error.description)
Colors.exit(withError: error) Colors.exit(withError: error)
} }
} }

View File

@ -29,7 +29,7 @@ struct ColorXcassetHelper {
withIntermediateDirectories: true) withIntermediateDirectories: true)
} catch { } catch {
let error = ColorsToolError.createAssetFolder(colorSetPath) let error = ColorsToolError.createAssetFolder(colorSetPath)
print(error.localizedDescription) print(error.description)
Colors.exit(withError: error) Colors.exit(withError: error)
} }
} }
@ -40,7 +40,7 @@ struct ColorXcassetHelper {
try color.contentsJSON().write(to: contentsJsonPathURL, atomically: false, encoding: .utf8) try color.contentsJSON().write(to: contentsJsonPathURL, atomically: false, encoding: .utf8)
} catch (let error) { } catch (let error) {
let error = ColorsToolError.writeAsset(error.localizedDescription) let error = ColorsToolError.writeAsset(error.localizedDescription)
print(error.localizedDescription) print(error.description)
Colors.exit(withError: error) Colors.exit(withError: error)
} }
} }

View File

@ -26,7 +26,7 @@ struct ParsedColor {
guard allComponents.contains(true) == false else { guard allComponents.contains(true) == false else {
let error = ColorsToolError.badColorDefinition(light, dark) let error = ColorsToolError.badColorDefinition(light, dark)
print(error.localizedDescription) print(error.description)
Colors.exit(withError: error) Colors.exit(withError: error)
} }

View File

@ -37,7 +37,7 @@ class ColorFileParser {
guard colorContent.count >= 2 else { guard colorContent.count >= 2 else {
let error = ColorsToolError.badFormat(colorLine) let error = ColorsToolError.badFormat(colorLine)
print(error.localizedDescription) print(error.description)
Colors.exit(withError: error) Colors.exit(withError: error)
} }

View File

@ -74,14 +74,14 @@ struct Fonts: ParsableCommand {
// Check input file exists // Check input file exists
guard fileManager.fileExists(atPath: options.inputFile) else { guard fileManager.fileExists(atPath: options.inputFile) else {
let error = FontsToolError.fileNotExists(options.inputFile) let error = FontsToolError.fileNotExists(options.inputFile)
print(error.localizedDescription) print(error.description)
Fonts.exit(withError: error) Fonts.exit(withError: error)
} }
// Extension for UIKit and SwiftUI should have different name // Extension for UIKit and SwiftUI should have different name
guard options.extensionName != options.extensionNameSwiftUI else { guard options.extensionName != options.extensionNameSwiftUI else {
let error = FontsToolError.extensionNamesCollision(options.extensionName) let error = FontsToolError.extensionNamesCollision(options.extensionName)
print(error.localizedDescription) print(error.description)
Fonts.exit(withError: error) Fonts.exit(withError: error)
} }

View File

@ -17,19 +17,19 @@ enum FontsToolError: Error {
var localizedDescription: String { var localizedDescription: String {
switch self { switch self {
case .extensionNamesCollision(let extensionName): case .extensionNamesCollision(let extensionName):
return "error:[\(Fonts.toolName)] Error on extension names, extension name and SwiftUI extension name should be different (\(extensionName) is used on both)" return "error: [\(Fonts.toolName)] Error on extension names, extension name and SwiftUI extension name should be different (\(extensionName) is used on both)"
case .fcScan(let path, let code, let output): case .fcScan(let path, let code, let output):
return "error:[\(Fonts.toolName)] Error while getting fontName (fc-scan --format %{postscriptname} \(path). fc-scan exit with \(code) and output is: \(output ?? "no output")" return "error: [\(Fonts.toolName)] Error while getting fontName (fc-scan --format %{postscriptname} \(path). fc-scan exit with \(code) and output is: \(output ?? "no output")"
case .inputFolderNotFound(let inputFolder): case .inputFolderNotFound(let inputFolder):
return " error:[\(Fonts.toolName)] Input folder not found: \(inputFolder)" return "error: [\(Fonts.toolName)] Input folder not found: \(inputFolder)"
case .fileNotExists(let filename): case .fileNotExists(let filename):
return " error:[\(Fonts.toolName)] File \(filename) does not exists" return "error: [\(Fonts.toolName)] File \(filename) does not exists"
case .writeExtension(let filename, let info): case .writeExtension(let filename, let info):
return "error:[\(Fonts.toolName)] An error occured while writing extension in \(filename): \(info)" return "error: [\(Fonts.toolName)] An error occured while writing extension in \(filename): \(info)"
} }
} }
} }

View File

@ -39,7 +39,7 @@ class FontsToolHelper {
let fileManager = FileManager() let fileManager = FileManager()
guard fileManager.fileExists(atPath: inputFolder) else { guard fileManager.fileExists(atPath: inputFolder) else {
let error = FontsToolError.inputFolderNotFound(inputFolder) let error = FontsToolError.inputFolderNotFound(inputFolder)
print(error.localizedDescription) print(error.description)
Fonts.exit(withError: error) Fonts.exit(withError: error)
} }
@ -64,7 +64,7 @@ class FontsToolHelper {
guard let fontName = task.output, task.terminationStatus == 0 else { guard let fontName = task.output, task.terminationStatus == 0 else {
let error = FontsToolError.fcScan(path, task.terminationStatus, task.output) let error = FontsToolError.fcScan(path, task.terminationStatus, task.output)
print(error.localizedDescription) print(error.description)
Fonts.exit(withError: error) Fonts.exit(withError: error)
} }

View File

@ -38,7 +38,7 @@ class FontExtensionGenerator {
try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8) try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) { } catch (let error) {
let error = FontsToolError.writeExtension(extensionFilePath, error.localizedDescription) let error = FontsToolError.writeExtension(extensionFilePath, error.localizedDescription)
print(error.localizedDescription) print(error.description)
Fonts.exit(withError: error) Fonts.exit(withError: error)
} }
} }

View File

@ -16,19 +16,19 @@ enum GenerateError: Error {
var localizedDescription: String { var localizedDescription: String {
switch self { switch self {
case .fileNotExists(let filename): case .fileNotExists(let filename):
return " error:[\(Generate.toolName)] File \(filename) does not exists" return "error: [\(Generate.toolName)] File \(filename) does not exists"
case .invalidConfigurationFile(let filename): case .invalidConfigurationFile(let filename):
return " error:[\(Generate.toolName)] File \(filename) is not a valid configuration file" return "error: [\(Generate.toolName)] File \(filename) is not a valid configuration file"
case .commandError(let command, let terminationStatus): case .commandError(let command, let terminationStatus):
let readableCommand = command let readableCommand = command
.map { $0 } .map { $0 }
.joined(separator: " ") .joined(separator: " ")
return "error:[\(Generate.toolName)] An error occured while running command '\(readableCommand)'. Command terminate with status code: \(terminationStatus)" return "error: [\(Generate.toolName)] An error occured while running command '\(readableCommand)'. Command terminate with status code: \(terminationStatus)"
case .writeFile(let filename, let info): case .writeFile(let filename, let info):
return "error:[\(Generate.toolName)] An error occured while writing file in \(filename): \(info)" return "error: [\(Generate.toolName)] An error occured while writing file in \(filename): \(info)"
} }
} }
} }

View File

@ -20,7 +20,7 @@ struct ArchitectureGenerator {
let filename = "\(architecture.classname).swift" let filename = "\(architecture.classname).swift"
guard let filePath = architecture.path else { guard let filePath = architecture.path else {
let error = GenerateError.writeFile(filename, "Path of file is not defined.") let error = GenerateError.writeFile(filename, "Path of file is not defined.")
print(error.localizedDescription) print(error.description)
Generate.exit(withError: error) Generate.exit(withError: error)
} }
@ -30,7 +30,7 @@ struct ArchitectureGenerator {
try architectureContent.write(to: architectureFilePathURL, atomically: false, encoding: .utf8) try architectureContent.write(to: architectureFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) { } catch (let error) {
let error = GenerateError.writeFile(filename, error.localizedDescription) let error = GenerateError.writeFile(filename, error.localizedDescription)
print(error.localizedDescription) print(error.description)
Generate.exit(withError: error) Generate.exit(withError: error)
} }
} }

View File

@ -12,13 +12,13 @@ class ConfigurationFileParser {
static func parse(_ configurationFile: String) -> ConfigurationFile { static func parse(_ configurationFile: String) -> ConfigurationFile {
guard let data = FileManager().contents(atPath: configurationFile) else { guard let data = FileManager().contents(atPath: configurationFile) else {
let error = GenerateError.fileNotExists(configurationFile) let error = GenerateError.fileNotExists(configurationFile)
print(error.localizedDescription) print(error.description)
Generate.exit(withError: error) Generate.exit(withError: error)
} }
guard let configuration = try? YAMLDecoder().decode(ConfigurationFile.self, from: data) else { guard let configuration = try? YAMLDecoder().decode(ConfigurationFile.self, from: data) else {
let error = GenerateError.invalidConfigurationFile(configurationFile) let error = GenerateError.invalidConfigurationFile(configurationFile)
print(error.localizedDescription) print(error.description)
Generate.exit(withError: error) Generate.exit(withError: error)
} }

View File

@ -12,7 +12,7 @@ extension FileManager {
var files = [String]() var files = [String]()
guard let enumerator = self.enumerator(at: URL(string: directory)!, includingPropertiesForKeys: [.isRegularFileKey], options: [.skipsHiddenFiles, .skipsPackageDescendants]) else { guard let enumerator = self.enumerator(at: URL(string: directory)!, includingPropertiesForKeys: [.isRegularFileKey], options: [.skipsHiddenFiles, .skipsPackageDescendants]) else {
let error = ImagesError.unknown("Cannot enumerate file in \(directory)") let error = ImagesError.unknown("Cannot enumerate file in \(directory)")
print(error.localizedDescription) print(error.description)
Images.exit(withError: error) Images.exit(withError: error)
} }
@ -24,7 +24,7 @@ extension FileManager {
} }
} catch { } catch {
let error = ImagesError.getFileAttributed(fileURL.relativePath, error.localizedDescription) let error = ImagesError.getFileAttributed(fileURL.relativePath, error.localizedDescription)
print(error.localizedDescription) print(error.description)
Images.exit(withError: error) Images.exit(withError: error)
} }
} }
@ -35,7 +35,7 @@ extension FileManager {
var files = [String]() var files = [String]()
guard let enumerator = self.enumerator(at: URL(string: directory)!, includingPropertiesForKeys: [.isDirectoryKey], options: [.skipsHiddenFiles, .skipsPackageDescendants]) else { guard let enumerator = self.enumerator(at: URL(string: directory)!, includingPropertiesForKeys: [.isDirectoryKey], options: [.skipsHiddenFiles, .skipsPackageDescendants]) else {
let error = ImagesError.unknown("Cannot enumerate imageset directory in \(directory)") let error = ImagesError.unknown("Cannot enumerate imageset directory in \(directory)")
print(error.localizedDescription) print(error.description)
Images.exit(withError: error) Images.exit(withError: error)
} }
@ -47,7 +47,7 @@ extension FileManager {
} }
} catch { } catch {
let error = ImagesError.getFileAttributed(fileURL.relativePath, error.localizedDescription) let error = ImagesError.getFileAttributed(fileURL.relativePath, error.localizedDescription)
print(error.localizedDescription) print(error.description)
Images.exit(withError: error) Images.exit(withError: error)
} }
} }

View File

@ -31,7 +31,7 @@ class ImageExtensionGenerator {
try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8) try extensionContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) { } catch (let error) {
let error = ImagesError.writeFile(extensionFilePath, error.localizedDescription) let error = ImagesError.writeFile(extensionFilePath, error.localizedDescription)
print(error.localizedDescription) print(error.description)
Images.exit(withError: error) Images.exit(withError: error)
} }
} }

View File

@ -48,7 +48,7 @@ class XcassetsGenerator {
} }
} }
let error = ImagesError.unknownImageExtension(parsedImage.name) let error = ImagesError.unknownImageExtension(parsedImage.name)
print(error.localizedDescription) print(error.description)
Images.exit(withError: error) Images.exit(withError: error)
}() }()
@ -77,7 +77,7 @@ class XcassetsGenerator {
withIntermediateDirectories: true) withIntermediateDirectories: true)
} catch { } catch {
let error = ImagesError.createAssetFolder(imagesetPath) let error = ImagesError.createAssetFolder(imagesetPath)
print(error.localizedDescription) print(error.description)
Images.exit(withError: error) Images.exit(withError: error)
} }
} }

View File

@ -82,7 +82,7 @@ struct Images: ParsableCommand {
// Input file // Input file
guard fileManager.fileExists(atPath: options.inputFile) else { guard fileManager.fileExists(atPath: options.inputFile) else {
let error = ImagesError.fileNotExists(options.inputFile) let error = ImagesError.fileNotExists(options.inputFile)
print(error.localizedDescription) print(error.description)
Images.exit(withError: error) Images.exit(withError: error)
} }
@ -92,7 +92,7 @@ struct Images: ParsableCommand {
// Extension for UIKit and SwiftUI should have different name // Extension for UIKit and SwiftUI should have different name
guard options.extensionName != options.extensionNameSwiftUI else { guard options.extensionName != options.extensionNameSwiftUI else {
let error = ImagesError.extensionNamesCollision(options.extensionName) let error = ImagesError.extensionNamesCollision(options.extensionName)
print(error.localizedDescription) print(error.description)
Images.exit(withError: error) Images.exit(withError: error)
} }
@ -117,7 +117,7 @@ struct Images: ParsableCommand {
} }
let error = ImagesError.rsvgConvertNotFound let error = ImagesError.rsvgConvertNotFound
print(error.localizedDescription) print(error.description)
Images.exit(withError: error) Images.exit(withError: error)
} }
} }

View File

@ -21,31 +21,31 @@ enum ImagesError: Error {
var localizedDescription: String { var localizedDescription: String {
switch self { switch self {
case .extensionNamesCollision(let extensionName): case .extensionNamesCollision(let extensionName):
return "error:[\(Fonts.toolName)] Error on extension names, extension name and SwiftUI extension name should be different (\(extensionName) is used on both)" return "error: [\(Fonts.toolName)] Error on extension names, extension name and SwiftUI extension name should be different (\(extensionName) is used on both)"
case .inputFolderNotFound(let inputFolder): case .inputFolderNotFound(let inputFolder):
return " error:[\(Images.toolName)] Input folder not found: \(inputFolder)" return "error: [\(Images.toolName)] Input folder not found: \(inputFolder)"
case .fileNotExists(let filename): case .fileNotExists(let filename):
return " error:[\(Images.toolName)] File \(filename) does not exists" return "error: [\(Images.toolName)] File \(filename) does not exists"
case .unknownImageExtension(let filename): case .unknownImageExtension(let filename):
return " error:[\(Images.toolName)] File \(filename) have an unhandled file extension. Cannot generate image." return "error: [\(Images.toolName)] File \(filename) have an unhandled file extension. Cannot generate image."
case .getFileAttributed(let filename, let errorDescription): case .getFileAttributed(let filename, let errorDescription):
return " error:[\(Images.toolName)] Getting file attributes of \(filename) failed with error: \(errorDescription)" return "error: [\(Images.toolName)] Getting file attributes of \(filename) failed with error: \(errorDescription)"
case .rsvgConvertNotFound: case .rsvgConvertNotFound:
return " error:[\(Images.toolName)] Can't find rsvg-convert (can be installed with 'brew remove imagemagick && brew install imagemagick --with-librsvg')" return "error: [\(Images.toolName)] Can't find rsvg-convert (can be installed with 'brew remove imagemagick && brew install imagemagick --with-librsvg')"
case .writeFile(let subErrorDescription, let filename): case .writeFile(let subErrorDescription, let filename):
return " error:[\(Images.toolName)] An error occured while writing content to \(filename): \(subErrorDescription)" return "error: [\(Images.toolName)] An error occured while writing content to \(filename): \(subErrorDescription)"
case .createAssetFolder(let folder): case .createAssetFolder(let folder):
return "error:[\(Colors.toolName)] An error occured while creating folder `\(folder)`" return "error: [\(Colors.toolName)] An error occured while creating folder `\(folder)`"
case .unknown(let errorDescription): case .unknown(let errorDescription):
return " error:[\(Images.toolName)] Unknown error: \(errorDescription)" return "error: [\(Images.toolName)] Unknown error: \(errorDescription)"
} }
} }
} }

View File

@ -31,7 +31,7 @@ class StringsFileGenerator {
try fileContent.write(to: stringsFilePathURL, atomically: false, encoding: .utf8) try fileContent.write(to: stringsFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) { } catch (let error) {
let error = StringiumError.writeFile(error.localizedDescription, stringsFilePath) let error = StringiumError.writeFile(error.localizedDescription, stringsFilePath)
print(error.localizedDescription) print(error.description)
Stringium.exit(withError: error) Stringium.exit(withError: error)
} }
} }
@ -75,7 +75,7 @@ class StringsFileGenerator {
stringsFileContent += "\"\(definition.name)\" = \"\(translation)\";\n\n" stringsFileContent += "\"\(definition.name)\" = \"\(translation)\";\n\n"
} else if skipDefinition == false { } else if skipDefinition == false {
let error = StringiumError.langNotDefined(lang, definition.name, definition.reference != nil) let error = StringiumError.langNotDefined(lang, definition.name, definition.reference != nil)
print(error.localizedDescription) print(error.description)
Stringium.exit(withError: error) Stringium.exit(withError: error)
} }
} }
@ -101,7 +101,7 @@ class StringsFileGenerator {
try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8) try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) { } catch (let error) {
let error = StringiumError.writeFile(extensionFilePath, error.localizedDescription) let error = StringiumError.writeFile(extensionFilePath, error.localizedDescription)
print(error.localizedDescription) print(error.description)
Stringium.exit(withError: error) Stringium.exit(withError: error)
} }
} }

View File

@ -24,7 +24,7 @@ class TagsGenerator {
try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8) try extensionFileContent.write(to: extensionFilePathURL, atomically: false, encoding: .utf8)
} catch (let error) { } catch (let error) {
let error = StringiumError.writeFile(extensionFilePath, error.localizedDescription) let error = StringiumError.writeFile(extensionFilePath, error.localizedDescription)
print(error.localizedDescription) print(error.description)
Stringium.exit(withError: error) Stringium.exit(withError: error)
} }
} }

View File

@ -109,7 +109,7 @@ class Definition {
func getNSLocalizedStringProperty(forLang lang: String) -> String { func getNSLocalizedStringProperty(forLang lang: String) -> String {
guard let translation = translations[lang] else { guard let translation = translations[lang] else {
let error = StringiumError.langNotDefined(lang, name, reference != nil) let error = StringiumError.langNotDefined(lang, name, reference != nil)
print(error.localizedDescription) print(error.description)
Stringium.exit(withError: error) Stringium.exit(withError: error)
} }
@ -132,7 +132,7 @@ class Definition {
func getNSLocalizedStringStaticProperty(forLang lang: String) -> String { func getNSLocalizedStringStaticProperty(forLang lang: String) -> String {
guard let translation = translations[lang] else { guard let translation = translations[lang] else {
let error = StringiumError.langNotDefined(lang, name, reference != nil) let error = StringiumError.langNotDefined(lang, name, reference != nil)
print(error.localizedDescription) print(error.description)
Stringium.exit(withError: error) Stringium.exit(withError: error)
} }
@ -157,7 +157,7 @@ class Definition {
func getProperty(forLang lang: String) -> String { func getProperty(forLang lang: String) -> String {
guard let translation = translations[lang] else { guard let translation = translations[lang] else {
let error = StringiumError.langNotDefined(lang, name, reference != nil) let error = StringiumError.langNotDefined(lang, name, reference != nil)
print(error.localizedDescription) print(error.description)
Stringium.exit(withError: error) Stringium.exit(withError: error)
} }
@ -173,7 +173,7 @@ class Definition {
func getStaticProperty(forLang lang: String) -> String { func getStaticProperty(forLang lang: String) -> String {
guard let translation = translations[lang] else { guard let translation = translations[lang] else {
let error = StringiumError.langNotDefined(lang, name, reference != nil) let error = StringiumError.langNotDefined(lang, name, reference != nil)
print(error.localizedDescription) print(error.description)
Stringium.exit(withError: error) Stringium.exit(withError: error)
} }

View File

@ -84,7 +84,7 @@ class TwineFileParser {
} }
} }
if invalidDefinitionNames.count > 0 { if invalidDefinitionNames.count > 0 {
print(" warning:[\(Stringium.toolName)] Found \(invalidDefinitionNames.count) definition (\(invalidDefinitionNames.joined(separator: ", "))") print("warning: [\(Stringium.toolName)] Found \(invalidDefinitionNames.count) definition (\(invalidDefinitionNames.joined(separator: ", "))")
} }
return sections return sections

View File

@ -70,20 +70,20 @@ struct Stringium: ParsableCommand {
// Input file // Input file
guard fileManager.fileExists(atPath: options.inputFile) else { guard fileManager.fileExists(atPath: options.inputFile) else {
let error = StringiumError.fileNotExists(options.inputFile) let error = StringiumError.fileNotExists(options.inputFile)
print(error.localizedDescription) print(error.description)
Stringium.exit(withError: error) Stringium.exit(withError: error)
} }
// Langs // Langs
guard options.langs.isEmpty == false else { guard options.langs.isEmpty == false else {
let error = StringiumError.langsListEmpty let error = StringiumError.langsListEmpty
print(error.localizedDescription) print(error.description)
Stringium.exit(withError: error) Stringium.exit(withError: error)
} }
guard options.langs.contains(options.defaultLang) else { guard options.langs.contains(options.defaultLang) else {
let error = StringiumError.defaultLangsNotInLangs let error = StringiumError.defaultLangsNotInLangs
print(error.localizedDescription) print(error.description)
Stringium.exit(withError: error) Stringium.exit(withError: error)
} }

View File

@ -17,22 +17,22 @@ enum StringiumError: Error {
var localizedDescription: String { var localizedDescription: String {
switch self { switch self {
case .fileNotExists(let filename): case .fileNotExists(let filename):
return " error:[\(Stringium.toolName)] File \(filename) does not exists " return "error: [\(Stringium.toolName)] File \(filename) does not exists "
case .langsListEmpty: case .langsListEmpty:
return " error:[\(Stringium.toolName)] Langs list is empty" return "error: [\(Stringium.toolName)] Langs list is empty"
case .defaultLangsNotInLangs: case .defaultLangsNotInLangs:
return " error:[\(Stringium.toolName)] Langs list does not contains the default lang" return "error: [\(Stringium.toolName)] Langs list does not contains the default lang"
case .writeFile(let subErrorDescription, let filename): case .writeFile(let subErrorDescription, let filename):
return " error:[\(Stringium.toolName)] An error occured while writing content to \(filename): \(subErrorDescription)" return "error: [\(Stringium.toolName)] An error occured while writing content to \(filename): \(subErrorDescription)"
case .langNotDefined(let lang, let definitionName, let isReference): case .langNotDefined(let lang, let definitionName, let isReference):
if isReference { if isReference {
return " error:[\(Stringium.toolName)] Reference are handled only by TwineTool. Please use it or remove reference from you strings file." return "error: [\(Stringium.toolName)] Reference are handled only by Twine. Please use it or remove reference from you strings file."
} }
return " error:[\(Stringium.toolName)] Lang \"\(lang)\" not found for \"\(definitionName)\"" return "error: [\(Stringium.toolName)] Lang \"\(lang)\" not found for \"\(definitionName)\""
} }
} }
} }

View File

@ -62,7 +62,7 @@ struct Tags: ParsableCommand {
// Input file // Input file
guard fileManager.fileExists(atPath: options.inputFile) else { guard fileManager.fileExists(atPath: options.inputFile) else {
let error = StringiumError.fileNotExists(options.inputFile) let error = StringiumError.fileNotExists(options.inputFile)
print(error.localizedDescription) print(error.description)
Stringium.exit(withError: error) Stringium.exit(withError: error)
} }

View File

@ -66,20 +66,20 @@ struct Twine: ParsableCommand {
// Input file // Input file
guard fileManager.fileExists(atPath: options.inputFile) else { guard fileManager.fileExists(atPath: options.inputFile) else {
let error = TwineError.fileNotExists(options.inputFile) let error = TwineError.fileNotExists(options.inputFile)
print(error.localizedDescription) print(error.description)
Twine.exit(withError: error) Twine.exit(withError: error)
} }
// Langs // Langs
guard options.langs.isEmpty == false else { guard options.langs.isEmpty == false else {
let error = TwineError.langsListEmpty let error = TwineError.langsListEmpty
print(error.localizedDescription) print(error.description)
Twine.exit(withError: error) Twine.exit(withError: error)
} }
guard options.langs.contains(options.defaultLang) else { guard options.langs.contains(options.defaultLang) else {
let error = TwineError.defaultLangsNotInLangs let error = TwineError.defaultLangsNotInLangs
print(error.localizedDescription) print(error.description)
Twine.exit(withError: error) Twine.exit(withError: error)
} }

View File

@ -15,13 +15,13 @@ enum TwineError: Error {
var localizedDescription: String { var localizedDescription: String {
switch self { switch self {
case .fileNotExists(let filename): case .fileNotExists(let filename):
return " error:[\(Twine.toolName)] File \(filename) does not exists " return "error: [\(Twine.toolName)] File \(filename) does not exists "
case .langsListEmpty: case .langsListEmpty:
return " error:[\(Twine.toolName)] Langs list is empty" return "error: [\(Twine.toolName)] Langs list is empty"
case .defaultLangsNotInLangs: case .defaultLangsNotInLangs:
return " error:[\(Twine.toolName)] Langs list does not contains the default lang" return "error: [\(Twine.toolName)] Langs list does not contains the default lang"
} }
} }
} }