diff --git a/SampleFiles/genAllRessources.sh b/SampleFiles/genAllRessources.sh index ee35443..c1d139c 100755 --- a/SampleFiles/genAllRessources.sh +++ b/SampleFiles/genAllRessources.sh @@ -1,7 +1,7 @@ #/bin/bash # Font -swift run -c release FontToolCore "./Fonts/sampleFontsAll.txt" \ +swift run -c release FontToolCore "./Fonts/sampleFontsAl.txt" \ --extension-output-path "./Fonts/Generated" \ --extension-name "R2Font" \ --extension-suffix "GenAllScript" diff --git a/Sources/ColorToolCore/ColorToolError.swift b/Sources/ColorToolCore/ColorToolError.swift index b5a0f73..7b90073 100644 --- a/Sources/ColorToolCore/ColorToolError.swift +++ b/Sources/ColorToolCore/ColorToolError.swift @@ -17,37 +17,19 @@ enum ColorToolError: Error { var description: String { switch self { case .badFormat(let info): - return """ - [ColorTool] - Bad line format: \(info). Accepted format are: - - colorName="#RGB/#ARGB" - - colorName "#RGB/#ARGB" - - colorName "#RGB/#ARGB" "#RGB/#ARGB" - """ + return "error:[ColorTool] Bad line format: \(info). Accepted format are: colorName=\"#RGB/#ARGB\"; colorName \"#RGB/#ARGB\"; colorName \"#RGB/#ARGB\" \"#RGB/#ARGB\"" case .writeAsset(let info): - return """ - [ColorTool] - An error occured while writing color in Xcasset: \(info) - """ + return "error:[ColorTool] An error occured while writing color in Xcasset: \(info)" case .writeExtension(let filename, let info): - return """ - [ColorTool] - An error occured while writing extension in \(filename): \(info) - """ + return "error:[ColorTool] An error occured while writing extension in \(filename): \(info)" case .fileNotExists(let filename): - return """ - [ColorTool] - File \(filename) does not exists - """ + return "error:[ColorTool] File \(filename) does not exists" case .badColorDefinition(let lightColor, let darkColor): - return """ - [ColorTool] - One of these two colors has invalid synthax: -\(lightColor)- or -\(darkColor)- - """ + return "error:[ColorTool]One of these two colors has invalid synthax: -\(lightColor)- or -\(darkColor)-" } } } diff --git a/Sources/ColorToolCore/ColorXcassetHelper.swift b/Sources/ColorToolCore/ColorXcassetHelper.swift index d909e65..ec6e56f 100644 --- a/Sources/ColorToolCore/ColorXcassetHelper.swift +++ b/Sources/ColorToolCore/ColorXcassetHelper.swift @@ -34,7 +34,9 @@ struct ColorXcassetHelper { do { try color.contentsJSON().write(to: contentsJsonPathURL, atomically: true, encoding: .utf8) } catch (let error) { - ColorTool.exit(withError: ColorToolError.writeAsset(error.localizedDescription)) + let error = ColorToolError.writeAsset(error.localizedDescription) + print(error.localizedDescription) + ColorTool.exit(withError: error) } } } diff --git a/Sources/ColorToolCore/GenColor.swift b/Sources/ColorToolCore/GenColor.swift index 10526f3..2258fb0 100644 --- a/Sources/ColorToolCore/GenColor.swift +++ b/Sources/ColorToolCore/GenColor.swift @@ -25,7 +25,9 @@ struct GenColor { } guard allComponents.contains(true) == false else { - ColorTool.exit(withError: ColorToolError.badColorDefinition(light, dark)) + let error = ColorToolError.badColorDefinition(light, dark) + print(error.localizedDescription) + ColorTool.exit(withError: error) } return """ diff --git a/Sources/ColorToolCore/main.swift b/Sources/ColorToolCore/main.swift index b496ed7..f6aa216 100644 --- a/Sources/ColorToolCore/main.swift +++ b/Sources/ColorToolCore/main.swift @@ -52,10 +52,14 @@ struct ColorTool: ParsableCommand { // Check requirements let fileManager = FileManager() guard fileManager.fileExists(atPath: xcassetsPath) else { - ColorTool.exit(withError: ColorToolError.fileNotExists(xcassetsPath)) + let error = ColorToolError.fileNotExists(xcassetsPath) + print(error.localizedDescription) + ColorTool.exit(withError: error) } guard fileManager.fileExists(atPath: inputFile) else { - ColorTool.exit(withError: ColorToolError.fileNotExists(xcassetsPath)) + let error = ColorToolError.fileNotExists(inputFile) + print(error.localizedDescription) + ColorTool.exit(withError: error) } // Check if needed to regenerate @@ -103,7 +107,9 @@ struct ColorTool: ParsableCommand { do { try extensionContent.write(to: extensionFilePathURL, atomically: true, encoding: .utf8) } catch (let error) { - ColorTool.exit(withError: ColorToolError.writeExtension(extensionFilePath, error.localizedDescription)) + let error = ColorToolError.writeExtension(extensionFilePath, error.localizedDescription) + print(error.localizedDescription) + ColorTool.exit(withError: error) } } @@ -128,7 +134,9 @@ struct ColorTool: ParsableCommand { let colorContent = colorLineCleanedUp.split(separator: " ") guard colorContent.count >= 2 else { - ColorTool.exit(withError: ColorToolError.badFormat(colorLine)) + let error = ColorToolError.badFormat(colorLine) + print(error.localizedDescription) + ColorTool.exit(withError: error) } switch colorStyle { diff --git a/Sources/FontToolCore/FontToolError.swift b/Sources/FontToolCore/FontToolError.swift index 6f9ff04..d932155 100644 --- a/Sources/FontToolCore/FontToolError.swift +++ b/Sources/FontToolCore/FontToolError.swift @@ -13,26 +13,16 @@ enum FontToolError: Error { case inputFolderNotFound(String) case fileNotExists(String) - var description: String { + var localizedDescription: String { switch self { case .fcScan(let path, let code, let output): - return """ - error: [FontTool] - Error while getting fontName (fc-scan --format %{postscriptname} \(path). - fc-scan exit with \(code) and output is: \(output ?? "no output") - """ + return "error:[FontTool] Error while getting fontName (fc-scan --format %{postscriptname} \(path). fc-scan exit with \(code) and output is: \(output ?? "no output")" case .inputFolderNotFound(let inputFolder): - return """ - error: [FontTool] - Input folder not found: \(inputFolder) - """ + return " error:[FontTool] Input folder not found: \(inputFolder)" case .fileNotExists(let filename): - return """ - error: [FontTool] - File \(filename) does not exists - """ + return " error:[FontTool] File \(filename) does not exists " } } } diff --git a/Sources/FontToolCore/FontToolHelper.swift b/Sources/FontToolCore/FontToolHelper.swift index 55751c7..aea6118 100644 --- a/Sources/FontToolCore/FontToolHelper.swift +++ b/Sources/FontToolCore/FontToolHelper.swift @@ -13,7 +13,9 @@ class FontToolHelper { // Get a enumerator for all files let fileManager = FileManager() guard fileManager.fileExists(atPath: inputFolder) else { - FontTool.exit(withError: FontToolError.inputFolderNotFound(inputFolder)) + let error = FontToolError.inputFolderNotFound(inputFolder) + print(error.localizedDescription) + FontTool.exit(withError: error) } let enumerator: FileManager.DirectoryEnumerator = fileManager.enumerator(atPath: inputFolder)! @@ -41,7 +43,9 @@ class FontToolHelper { let task = Shell.shell("fc-scan", "--format", "%{postscriptname}", path) guard let fontName = task.output, task.terminationStatus == 0 else { - FontTool.exit(withError: FontToolError.fcScan(path, task.terminationStatus, task.output)) + let error = FontToolError.fcScan(path, task.terminationStatus, task.output) + print(error.localizedDescription) + FontTool.exit(withError: error) } return fontName diff --git a/Sources/FontToolCore/main.swift b/Sources/FontToolCore/main.swift index a8e7f90..099a788 100644 --- a/Sources/FontToolCore/main.swift +++ b/Sources/FontToolCore/main.swift @@ -41,7 +41,9 @@ struct FontTool: ParsableCommand { // Check requirements let fileManager = FileManager() guard fileManager.fileExists(atPath: inputFile) else { - FontTool.exit(withError: FontToolError.fileNotExists(inputFile)) + let error = FontToolError.fileNotExists(inputFile) + print(error.localizedDescription) + FontTool.exit(withError: error) } // Check if needed to regenerate