diff options
15 files changed, 17 insertions, 20 deletions
diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/Command.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/Command.scala index 062fefe..55635d9 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/Command.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/Command.scala @@ -6,16 +6,15 @@ trait Command { def help(): Unit - final def error(error: Throwable)(implicit options: OptionMap): Unit = { + final def error(error: Throwable, options: OptionMap): Unit = if (!isUnitTest(options)) { println(error.getMessage) sys.exit(1) } else throw error - } def execute(options: OptionMap): Unit - final def exit(implicit options: OptionMap): Unit = + final def exit(options: OptionMap): Unit = if (!isUnitTest(options)) sys.exit(0) protected[this] def isUnitTest(options: OptionMap): Boolean = diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/OptionMapUtility.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/OptionMapUtility.scala index 0086f84..224eff1 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/OptionMapUtility.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/OptionMapUtility.scala @@ -31,14 +31,12 @@ object OptionMapUtility { case single(name, value) :: tail => next(optionMap + (Symbol(name.tail) -> ""), tail) // Dashless options. - case less(value) :: tail if value.head != '-' => { + case less(value) :: tail if value.head != '-' => if (optionMap.contains('dashless)) { val dashless = optionMap('dashless) + " " + value.trim next((optionMap - 'dashless) + ('dashless -> dashless), tail) - } else - next(optionMap + ('dashless -> value.trim), tail) - } + } else next(optionMap + ('dashless -> value.trim), tail) // Invalid option, ignore. case _ :: tail => next(optionMap, tail) } diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/metaphoneAlgorithm.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/metaphoneAlgorithm.scala index 673812f..2655c88 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/metaphoneAlgorithm.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/metaphoneAlgorithm.scala @@ -24,7 +24,7 @@ object metaphoneAlgorithm extends Command { // Invalid syntax. } else throw new IllegalArgumentException("Expected valid syntax. See --help.") } catch { - case e => error(e)(options) + case e => error(e, options) } } diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/metaphoneMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/metaphoneMetric.scala index a915710..683fc9e 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/metaphoneMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/metaphoneMetric.scala @@ -24,7 +24,7 @@ object metaphoneMetric extends Command { // Invalid syntax. } else throw new IllegalArgumentException("Expected valid syntax. See --help.") } catch { - case e => error(e)(options) + case e => error(e, options) } } diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/nysiisAlgorithm.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/nysiisAlgorithm.scala index cf71bf5..08dcbef 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/nysiisAlgorithm.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/nysiisAlgorithm.scala @@ -24,7 +24,7 @@ object nysiisAlgorithm extends Command { // Invalid syntax. } else throw new IllegalArgumentException("Expected valid syntax. See --help.") } catch { - case e => error(e)(options) + case e => error(e, options) } } diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/nysiisMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/nysiisMetric.scala index b9a1b3e..da83a35 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/nysiisMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/nysiisMetric.scala @@ -24,7 +24,7 @@ object nysiisMetric extends Command { // Invalid syntax. } else throw new IllegalArgumentException("Expected valid syntax. See --help.") } catch { - case e => error(e)(options) + case e => error(e, options) } } diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedSoundexAlgorithm.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedSoundexAlgorithm.scala index 5ac8eb6..00c7900 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedSoundexAlgorithm.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedSoundexAlgorithm.scala @@ -24,7 +24,7 @@ object refinedSoundexAlgorithm extends Command { // Invalid syntax. } else throw new IllegalArgumentException("Expected valid syntax. See --help.") } catch { - case e => error(e)(options) + case e => error(e, options) } } diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedSoundexMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedSoundexMetric.scala index 02740ce..9a504b5 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedSoundexMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedSoundexMetric.scala @@ -24,7 +24,7 @@ object refinedSoundexMetric extends Command { // Invalid syntax. } else throw new IllegalArgumentException("Expected valid syntax. See --help.") } catch { - case e => error(e)(options) + case e => error(e, options) } } diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/soundexAlgorithm.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/soundexAlgorithm.scala index f879566..6874e67 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/soundexAlgorithm.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/soundexAlgorithm.scala @@ -24,7 +24,7 @@ object soundexAlgorithm extends Command { // Invalid syntax. } else throw new IllegalArgumentException("Expected valid syntax. See --help.") } catch { - case e => error(e)(options) + case e => error(e, options) } } diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/soundexMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/soundexMetric.scala index 0cac5cc..a06db9a 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/soundexMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/soundexMetric.scala @@ -24,7 +24,7 @@ object soundexMetric extends Command { // Invalid syntax. } else throw new IllegalArgumentException("Expected valid syntax. See --help.") } catch { - case e => error(e)(options) + case e => error(e, options) } } diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/diceSorensenMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/diceSorensenMetric.scala index 1f2bdee..684fb51 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/diceSorensenMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/diceSorensenMetric.scala @@ -24,7 +24,7 @@ object diceSorensenMetric extends Command { // Invalid syntax. } else throw new IllegalArgumentException("Expected valid syntax. See --help.") } catch { - case e => error(e)(options) + case e => error(e, options) } } diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/hammingMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/hammingMetric.scala index 0813e5e..adc3cf9 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/hammingMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/hammingMetric.scala @@ -24,7 +24,7 @@ object hammingMetric extends Command { // Invalid syntax. } else throw new IllegalArgumentException("Expected valid syntax. See --help.") } catch { - case e => error(e)(options) + case e => error(e, options) } } diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/jaroMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/jaroMetric.scala index 3c5cc73..67ceeee 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/jaroMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/jaroMetric.scala @@ -24,7 +24,7 @@ object jaroMetric extends Command { // Invalid syntax. } else throw new IllegalArgumentException("Expected valid syntax. See --help.") } catch { - case e => error(e)(options) + case e => error(e, options) } } diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/jaroWinklerMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/jaroWinklerMetric.scala index 8cbcca8..1908233 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/jaroWinklerMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/jaroWinklerMetric.scala @@ -24,7 +24,7 @@ object jaroWinklerMetric extends Command { // Invalid syntax. } else throw new IllegalArgumentException("Expected valid syntax. See --help.") } catch { - case e => error(e)(options) + case e => error(e, options) } } diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/levenshteinMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/levenshteinMetric.scala index aed6fcb..09a82bc 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/levenshteinMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/levenshteinMetric.scala @@ -24,7 +24,7 @@ object levenshteinMetric extends Command { // Invalid syntax. } else throw new IllegalArgumentException("Expected valid syntax. See --help.") } catch { - case e => error(e)(options) + case e => error(e, options) } } |