Tatsuo Ikeda avatar Tatsuo Ikeda committed 6f9ec26 Merge

merge add-scala

Comments (0)

Files changed (3)

 
 ##### IDE jetbrains
 .idea
+*.iml
 
 ##### TAG
 tags
 dist
 django_pudebug.egg-info
 
+##### scala
+lib/vetags/lang/scala/sources
+
+

lib/vetags/lang/scala/OptionParser.scala

+
+/*
+  #: TODO Constructorで初期値書き換え
+*/
+/*case */class OptionParser {
+
+  val PRODUCT: String = "createtags-scala"
+  val VERSION: String = "0.1"
+  val versionMessage = PRODUCT + " " + VERSION
+  val helpMessage = """
+  Usage: """ + PRODUCT + """ [OPTION...] [PATH]
+
+  Options::
+
+    -h                   --help                                show this help message and exit.
+    -v                   --version                             output the version number.
+    -a                   --all                                 all in virtualenv packages. ignore all options.
+    -p PACKAGES          --packages=PACKAGES                   give packages name. default is a `haskell` package.
+    -s STANDARDPACKAGES  --standard-packages=STANDARDPACKAGES  give packages name. for the standard library.
+                         --no-sbt                              not include the sbt library.
+                         --allow-testcode                      include the test code.
+  """
+
+  var path = ""
+  var all = false
+  var packages = ""
+  var spackages = ""
+  var sbt = true
+  var allowTestcode = false
+
+  def parse(args: List[String]): List[String] = {
+    args match {
+
+      case ("-a" | "--all") :: rest =>
+        all = true
+        parse(rest)
+
+      case ("-p" | "--packages") :: packages :: rest =>
+        this.packages = packages
+        parse(rest)
+
+      case ("-p" | "--packages") :: Nil =>
+        println("Option (-p | --packages) requires an argument")
+        sys.exit(1)
+
+      case ("-s" | "--standard-packages") :: spackages :: rest =>
+        this.spackages = spackages
+        parse(rest)
+
+      case ("-s" | "--standard-packages") :: Nil =>
+        println("Option (-s | --standard-packages) requires an argument")
+        sys.exit(1)
+
+      case ("--no-sbt") :: rest =>
+        sbt = false
+        parse(rest)
+
+      case ("--allow-testcode") :: rest =>
+        allowTestcode = true
+        parse(rest)
+
+      case ("-h" | "--help") :: rest =>
+        Console.println(helpMessage)
+        sys.exit(0)
+
+      case ("-v" | "--version" | "-varsion") :: rest =>
+        Console.println(versionMessage)
+        sys.exit(0)
+
+      case _ =>
+        path = args.mkString(" ")
+        args
+
+    }
+  }
+
+  override def toString = "OptionParser(" +
+    "path: " + path +
+    ", all: " + all +
+    ", packages: " + packages +
+    ", spackages: " + spackages +
+    ", sbt: " + sbt +
+    ", allowTestcode: " + allowTestcode +
+    ")"
+}
+
+
+object OptionParser {
+  def main(args: Array[String]) {
+
+    val opts = new OptionParser
+    opts.parse(args.toList)
+
+    Console.println(opts)
+  }
+}
+
+
+/* vim: set et fenc=utf-8 ft=scala ff=unix sts=0 sw=2 ts=2 : */

lib/vetags/lang/scala/createtags-scala

-#!/bin/sh
-exec scala -deprecation "$0" "$@"
-!#
-
-val PRODUCT: String = "createtags-scala"
-val VERSION: String = "0.1"
-val versionMessage = PRODUCT + " " + VERSION
-
-val helpMessage = """
-Usage: """ + PRODUCT + """ [OPTION...] [PATH]
-
-Options::
-
-  -h                   --help                                show this help message and exit.
-  -v                   --version                             output the version number.
-  -a                   --all                                 all in virtualenv packages. ignore all options.
-  -p PACKAGES          --packages=PACKAGES                   give packages name. default is a `haskell` package.
-  -s STANDARDPACKAGES  --standard-packages=STANDARDPACKAGES  give packages name. for the standard library.
-                       --no-sbt                              not include the sbt library.
-                       --allow-testcode                      include the test code.
-"""
-
-case class Args(newLine: Boolean, repeat: Int, message: String)
-
-def parseArgs(args: List[String]): Option[Args] = {
-
-  var newLine = true
-  var repeat = 1
-  var help = false
-
-  @scala.annotation.tailrec
-  def parseArgsHelper(args: List[String]): Args = {
-    args match {
-      case "-a" :: rest => {
-        newLine = false
-        parseArgsHelper(rest)
-      }
-
-      case "-p" :: x :: rest => {
-        repeat = x.toInt
-        parseArgsHelper(rest)
-      }
-
-      case ("-h" | "--help") :: rest => {
-        Console.println(helpMessage)
-        sys.exit(0)
-      }
-
-      case ("-v" | "--version") :: rest => {
-        Console.println(versionMessage)
-        sys.exit(0)
-      }
-
-      case message =>
-        Args(newLine, repeat, message.mkString(" "))
-    }
-  }
-
-  try { Some(parseArgsHelper(args)) } catch { case _ =>  None }
-
-}
-
-def __(args: Args): Unit = args match {
-  case Args(true, repeat, message) => (1 to repeat) foreach { _ => println(message) }
-  case Args(false, repeat, message) => (1 to repeat) foreach { _ => print(message) }
-}
-
-def main = parseArgs(args.toList) match {
-  case Some(args) => __(args)
-  case None => println("Invalid Arguments!")
-}
-
-main
-
-
-
-// vim: set et fenc= ft=scala ff=unix sts=0 sw=2 ts=2 :
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.