summaryrefslogtreecommitdiff
path: root/cli/source
diff options
context:
space:
mode:
authorRocky Madden <git@rockymadden.com>2012-10-26 19:50:43 -0600
committerRocky Madden <git@rockymadden.com>2012-10-26 19:50:43 -0600
commit3145e7e6f7ef496b27c9ed87cfd716cd23bf7291 (patch)
tree316cf1fbb2539c095a3742b54d3aac50a7332418 /cli/source
parentce234db3048af3d7cb5c825c8e217a9169ab5c3b (diff)
downloadstringmetric-3145e7e6f7ef496b27c9ed87cfd716cd23bf7291.tar.gz
stringmetric-3145e7e6f7ef496b27c9ed87cfd716cd23bf7291.tar.bz2
stringmetric-3145e7e6f7ef496b27c9ed87cfd716cd23bf7291.zip
Code formatting tweaks.
Diffstat (limited to 'cli/source')
-rwxr-xr-xcli/source/core/scala/org/hashtree/stringmetric/cli/OptionMapUtility.scala27
-rwxr-xr-xcli/source/core/scala/org/hashtree/stringmetric/cli/command/Command.scala20
-rwxr-xr-xcli/source/core/scala/org/hashtree/stringmetric/cli/command/diceSorensenMetric.scala4
-rwxr-xr-xcli/source/core/scala/org/hashtree/stringmetric/cli/command/hammingMetric.scala4
-rwxr-xr-xcli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroMetric.scala4
-rwxr-xr-xcli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroWinklerMetric.scala4
-rwxr-xr-xcli/source/core/scala/org/hashtree/stringmetric/cli/command/levenshteinMetric.scala4
-rwxr-xr-xcli/source/core/scala/org/hashtree/stringmetric/cli/command/metaphoneMetric.scala4
-rwxr-xr-xcli/source/core/scala/org/hashtree/stringmetric/cli/command/nysiisMetric.scala4
-rwxr-xr-xcli/source/core/scala/org/hashtree/stringmetric/cli/command/soundexMetric.scala4
10 files changed, 23 insertions, 56 deletions
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 cb13617..0086f84 100755
--- a/cli/source/core/scala/org/hashtree/stringmetric/cli/OptionMapUtility.scala
+++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/OptionMapUtility.scala
@@ -5,13 +5,9 @@ import scala.collection.immutable.HashMap
/** Utility standalone for OptionMap based operations. */
object OptionMapUtility {
- def toOptionMap(arguments: Array[String]): OptionMap = {
- toOptionMap(arguments.toList)
- }
+ def toOptionMap(arguments: Array[String]): OptionMap = toOptionMap(arguments.toList)
- def toOptionMap(arguments: List[String]): OptionMap = {
- next(HashMap.empty[Symbol, String], arguments)
- }
+ def toOptionMap(arguments: List[String]): OptionMap = next(HashMap.empty[Symbol, String], arguments)
@tailrec
private[this] def next(optionMap: OptionMap, arguments: List[String]): OptionMap = {
@@ -23,35 +19,28 @@ object OptionMapUtility {
// Empty List, return OptionMap.
case Nil => optionMap
// Double dash options, without value.
- case double(name, null) :: tail => {
+ case double(name, null) :: tail =>
next(optionMap + (Symbol(name.tail.tail) -> ""), tail)
- }
// Double dash options, with value.
- case double(name, value) :: tail => {
+ case double(name, value) :: tail =>
next(optionMap + (Symbol(name.tail.tail) -> value.tail), tail)
- }
// Single dash options, without value.
- case single(name, null) :: tail => {
+ case single(name, null) :: tail =>
next(optionMap + (Symbol(name.tail) -> ""), tail)
- }
// Single dash options, with value. Value is discarded.
- case single(name, value) :: tail => {
+ case single(name, value) :: tail =>
next(optionMap + (Symbol(name.tail) -> ""), tail)
- }
// Dashless options.
case less(value) :: tail if value.head != '-' => {
if (optionMap.contains('dashless)) {
val dashless = optionMap('dashless) + " " + value.trim
next((optionMap - 'dashless) + ('dashless -> dashless), tail)
- } else {
+ } else
next(optionMap + ('dashless -> value.trim), tail)
- }
}
// Invalid option, ignore.
- case _ :: tail => {
- next(optionMap, tail)
- }
+ case _ :: tail => next(optionMap, tail)
}
}
} \ No newline at end of file
diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/Command.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/Command.scala
index bac7786..77324b8 100755
--- a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/Command.scala
+++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/Command.scala
@@ -9,26 +9,20 @@ trait Command {
def help(): Unit
final def error(error: Throwable)(implicit options: OptionMap): Unit = {
- if (! isUnitTest(options)) {
+ if (!isUnitTest(options)) {
println(error.getMessage)
sys.exit(1)
- } else {
- throw error
- }
+ } else throw error
}
def execute(options: OptionMap): Unit
- final def exit(implicit options: OptionMap): Unit = {
- if (! isUnitTest(options)) sys.exit(0)
- }
+ final def exit(implicit options: OptionMap): Unit =
+ if (!isUnitTest(options)) sys.exit(0)
- protected[this] def isUnitTest(options: OptionMap): Boolean = {
+ protected[this] def isUnitTest(options: OptionMap): Boolean =
(options.contains('ut) || (options.contains('unitTest) && options.get('unitTest) != "false"))
- }
- protected[this] def isDebug(options: OptionMap): Boolean = {
+ protected[this] def isDebug(options: OptionMap): Boolean =
(options.contains('d) || (options.contains('debug) && options.get('debug) != "false"))
- }
-}
-
+} \ No newline at end of file
diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/diceSorensenMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/diceSorensenMetric.scala
index bddae46..d1e7d32 100755
--- a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/diceSorensenMetric.scala
+++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/diceSorensenMetric.scala
@@ -23,9 +23,7 @@ object diceSorensenMetric extends Command {
execute(options)
exit(options)
// Invalid syntax.
- } else {
- throw new IllegalArgumentException("Expected valid syntax. See --help.")
- }
+ } else throw new IllegalArgumentException("Expected valid syntax. See --help.")
} catch {
case e => error(e)(options)
}
diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/hammingMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/hammingMetric.scala
index cdb1864..b336cf5 100755
--- a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/hammingMetric.scala
+++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/hammingMetric.scala
@@ -23,9 +23,7 @@ object hammingMetric extends Command {
execute(options)
exit(options)
// Invalid syntax.
- } else {
- throw new IllegalArgumentException("Expected valid syntax. See --help.")
- }
+ } else throw new IllegalArgumentException("Expected valid syntax. See --help.")
} catch {
case e => error(e)(options)
}
diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroMetric.scala
index 7e9fa07..cb12910 100755
--- a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroMetric.scala
+++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroMetric.scala
@@ -23,9 +23,7 @@ object jaroMetric extends Command {
execute(options)
exit(options)
// Invalid syntax.
- } else {
- throw new IllegalArgumentException("Expected valid syntax. See --help.")
- }
+ } else throw new IllegalArgumentException("Expected valid syntax. See --help.")
} catch {
case e => error(e)(options)
}
diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroWinklerMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroWinklerMetric.scala
index bfaa7e9..75ddc8b 100755
--- a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroWinklerMetric.scala
+++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroWinklerMetric.scala
@@ -23,9 +23,7 @@ object jaroWinklerMetric extends Command {
execute(options)
exit(options)
// Invalid syntax.
- } else {
- throw new IllegalArgumentException("Expected valid syntax. See --help.")
- }
+ } else throw new IllegalArgumentException("Expected valid syntax. See --help.")
} catch {
case e => error(e)(options)
}
diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/levenshteinMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/levenshteinMetric.scala
index 1364a5a..7044062 100755
--- a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/levenshteinMetric.scala
+++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/levenshteinMetric.scala
@@ -23,9 +23,7 @@ object levenshteinMetric extends Command {
execute(options)
exit(options)
// Invalid syntax.
- } else {
- throw new IllegalArgumentException("Expected valid syntax. See --help.")
- }
+ } else throw new IllegalArgumentException("Expected valid syntax. See --help.")
} catch {
case e => error(e)(options)
}
diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/metaphoneMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/metaphoneMetric.scala
index 6e46de9..1d0b174 100755
--- a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/metaphoneMetric.scala
+++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/metaphoneMetric.scala
@@ -23,9 +23,7 @@ object metaphoneMetric extends Command {
execute(options)
exit(options)
// Invalid syntax.
- } else {
- throw new IllegalArgumentException("Expected valid syntax. See --help.")
- }
+ } else throw new IllegalArgumentException("Expected valid syntax. See --help.")
} catch {
case e => error(e)(options)
}
diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/nysiisMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/nysiisMetric.scala
index d49b99e..741cea2 100755
--- a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/nysiisMetric.scala
+++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/nysiisMetric.scala
@@ -23,9 +23,7 @@ object nysiisMetric extends Command {
execute(options)
exit(options)
// Invalid syntax.
- } else {
- throw new IllegalArgumentException("Expected valid syntax. See --help.")
- }
+ } else throw new IllegalArgumentException("Expected valid syntax. See --help.")
} catch {
case e => error(e)(options)
}
diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/soundexMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/soundexMetric.scala
index c9590c3..b49eadc 100755
--- a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/soundexMetric.scala
+++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/soundexMetric.scala
@@ -23,9 +23,7 @@ object soundexMetric extends Command {
execute(options)
exit(options)
// Invalid syntax.
- } else {
- throw new IllegalArgumentException("Expected valid syntax. See --help.")
- }
+ } else throw new IllegalArgumentException("Expected valid syntax. See --help.")
} catch {
case e => error(e)(options)
}