From 9319f7e07a0602fcc17c1bfb7eb78247967a1ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?He=CC=80ctor=20Marque=CC=80s?= Date: Thu, 3 Oct 2019 08:58:45 +0200 Subject: [PATCH] Reuse parseArguments error object --- Sources/UnstringifyFramework/ParseArgumentsError.swift | 6 ++++++ .../findAndroidStrings/Internal/parseArguments.swift | 10 +++------- Sources/findStrings/Internal/parseArguments.swift | 10 +++------- Sources/unstringify/Internal/parseArguments.swift | 10 +++------- Unstringified.podspec | 2 +- Unstringify.podspec | 2 +- 6 files changed, 17 insertions(+), 23 deletions(-) create mode 100755 Sources/UnstringifyFramework/ParseArgumentsError.swift diff --git a/Sources/UnstringifyFramework/ParseArgumentsError.swift b/Sources/UnstringifyFramework/ParseArgumentsError.swift new file mode 100755 index 0000000..0a0f9e6 --- /dev/null +++ b/Sources/UnstringifyFramework/ParseArgumentsError.swift @@ -0,0 +1,6 @@ +import Foundation + +public enum ParseArgumentsError: Swift.Error { + case tooFewArguments + case tooManyArguments +} diff --git a/Sources/findAndroidStrings/Internal/parseArguments.swift b/Sources/findAndroidStrings/Internal/parseArguments.swift index 23f8448..8b73ee3 100755 --- a/Sources/findAndroidStrings/Internal/parseArguments.swift +++ b/Sources/findAndroidStrings/Internal/parseArguments.swift @@ -1,23 +1,19 @@ import Foundation +import UnstringifyFramework typealias Arguments = (localizablePath: String, rootPath: String, outputPath: String, excludedFile: String) func parseArguments(from arguments: [String] = CommandLine.arguments) throws -> Arguments { - enum Error: Swift.Error { - case tooFewArguments - case tooManyArguments - } - func printUsage() { print("\nUsage: \(arguments[0]) localizable_strings_path android_project_root_path csv_output_path [excluded_file]\n") } if arguments.count < 4 { printUsage() - throw Error.tooFewArguments + throw ParseArgumentsError.tooFewArguments } else if arguments.count > 5 { printUsage() - throw Error.tooManyArguments + throw ParseArgumentsError.tooManyArguments } if arguments.count == 5 { diff --git a/Sources/findStrings/Internal/parseArguments.swift b/Sources/findStrings/Internal/parseArguments.swift index 9453812..b3679de 100755 --- a/Sources/findStrings/Internal/parseArguments.swift +++ b/Sources/findStrings/Internal/parseArguments.swift @@ -1,23 +1,19 @@ import Foundation +import UnstringifyFramework typealias Arguments = (rootPath: String, localizablePath: String, outputPath: String, excludedFile: String) func parseArguments(from arguments: [String] = CommandLine.arguments) throws -> Arguments { - enum Error: Swift.Error { - case tooFewArguments - case tooManyArguments - } - func printUsage() { print("\nUsage: \(arguments[0]) root_path localizable_path output_path [excluded_file]\n") } if arguments.count < 4 { printUsage() - throw Error.tooFewArguments + throw ParseArgumentsError.tooFewArguments } else if arguments.count > 5 { printUsage() - throw Error.tooManyArguments + throw ParseArgumentsError.tooManyArguments } if arguments.count == 5 { diff --git a/Sources/unstringify/Internal/parseArguments.swift b/Sources/unstringify/Internal/parseArguments.swift index 0d8bbda..86ecb64 100755 --- a/Sources/unstringify/Internal/parseArguments.swift +++ b/Sources/unstringify/Internal/parseArguments.swift @@ -1,23 +1,19 @@ import Foundation +import UnstringifyFramework typealias Arguments = (localizablePath: String, outputPath: String) func parseArguments(from arguments: [String] = CommandLine.arguments) throws -> Arguments { - enum Error: Swift.Error { - case tooFewArguments - case tooManyArguments - } - func printUsage() { print("\nUsage: \(arguments[0]) inputPath outputPath\n") } if arguments.count < 3 { printUsage() - throw Error.tooFewArguments + throw ParseArgumentsError.tooFewArguments } else if arguments.count > 3 { printUsage() - throw Error.tooManyArguments + throw ParseArgumentsError.tooManyArguments } return (arguments[1], arguments[2]) } diff --git a/Unstringified.podspec b/Unstringified.podspec index 7f861bc..e94a41e 100644 --- a/Unstringified.podspec +++ b/Unstringified.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Unstringified' - s.version = '0.1.0' + s.version = '0.2.0' s.summary = 'Strong-typed localizable strings static code.' s.homepage = 'https://github.com/metrolab/Unstringify' s.license = 'MIT' diff --git a/Unstringify.podspec b/Unstringify.podspec index ea098cb..3527699 100644 --- a/Unstringify.podspec +++ b/Unstringify.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Unstringify' - s.version = '0.1.0' + s.version = '0.2.0' s.summary = 'Code generator for strong-typing localizable strings.' s.homepage = 'https://github.com/metrolab/Unstringify' s.license = 'MIT'