Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
Reuse parseArguments error object
Browse files Browse the repository at this point in the history
  • Loading branch information
hectr committed Oct 3, 2019
1 parent 02c38f0 commit 9319f7e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 23 deletions.
6 changes: 6 additions & 0 deletions Sources/UnstringifyFramework/ParseArgumentsError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation

public enum ParseArgumentsError: Swift.Error {
case tooFewArguments
case tooManyArguments
}
10 changes: 3 additions & 7 deletions Sources/findAndroidStrings/Internal/parseArguments.swift
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
10 changes: 3 additions & 7 deletions Sources/findStrings/Internal/parseArguments.swift
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
10 changes: 3 additions & 7 deletions Sources/unstringify/Internal/parseArguments.swift
Original file line number Diff line number Diff line change
@@ -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])
}
2 changes: 1 addition & 1 deletion Unstringified.podspec
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion Unstringify.podspec
Original file line number Diff line number Diff line change
@@ -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'
Expand Down

0 comments on commit 9319f7e

Please sign in to comment.