diff options
Diffstat (limited to 'cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/metaphoneAlgorithm.scala')
-rwxr-xr-x | cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/metaphoneAlgorithm.scala | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/metaphoneAlgorithm.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/metaphoneAlgorithm.scala index 8ef925b..ed2207e 100755 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/metaphoneAlgorithm.scala +++ b/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/metaphoneAlgorithm.scala @@ -9,19 +9,17 @@ import com.rockymadden.stringmetric.phonetic.MetaphoneAlgorithm */ object metaphoneAlgorithm extends Command { override def main(args: Array[String]): Unit = { - val options = OptionMap(args) + val opts: OptionMap = args try - if (options.contains('h) || options.contains('help)) { + if (opts.contains('h) || opts.contains('help)) { help() - exit(options) - } else if (options.contains('dashless) && (options('dashless): OptionMapArray).length == 1) { - execute(options) - exit(options) + exit(opts) + } else if (opts.contains('dashless) && (opts('dashless): Array[String]).length == 1) { + execute(opts) + exit(opts) } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { - case e: Throwable => error(e, options) - } + catch { case e: Throwable => error(e, opts) } } override def help(): Unit = { @@ -34,10 +32,10 @@ object metaphoneAlgorithm extends Command { tab + "metaphoneAlgorithm [Options] string..." + ls + ls + "Options:" + ls + tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and options." + tab + tab + "Outputs description, syntax, and opts." ) } - override def execute(options: OptionMap): Unit = - println(MetaphoneAlgorithm.compute(options('dashless)).getOrElse("not computable")) + override def execute(opts: OptionMap): Unit = + println(MetaphoneAlgorithm.compute(opts('dashless)).getOrElse("not computable")) } |