GitHub PullRequestReviewCommentEvent at 2014-05-27 19:16:38
Repository: scala-commons
Actor: coderunner
Payload: {"comment":{"url":"https://api.github.com/repos/wajam/scala-commons/pulls/comments/13096388","id":13096388,"diff_hunk":"@@ -0,0 +1,117 @@\n+package com.wajam.script\n+\n+import com.wajam.commons.Logging\n+import com.wajam.script.Script.Executor\n+import scala.collection.mutable.ListBuffer\n+\n+trait Script extends DelayedInit with Logging {\n+\n+  protected var steps = scala.collection.mutable.MutableList[ScriptStep]()\n+\n+  protected def addStep(step: ScriptStep) = {\n+    steps += step\n+    step\n+  }\n+\n+  implicit class desc2in(desc: String) {\n+\n+    def in(executor: Executor) = execs(executor)\n+\n+    def updates(executor: Executor) = execs(executor)\n+\n+    def extracts(executor: Executor) = execs(executor)\n+\n+    def execs(executor: Executor): ScriptStep = {\n+      addStep(new ScriptStep {\n+        def execute() = executor.execute()\n+\n+        val description = desc\n+      })\n+    }\n+\n+    def execs[T](f: => T): ScriptStep = execs(new Executor {\n+      def execute(): Unit = f\n+    })\n+\n+    def prints(text: String) = execs(new Executor {\n+      def execute() {\n+        println(text)\n+      }\n+    })\n+  }\n+\n+  def showMenu() {\n+    initialize()\n+\n+    def validChoice(choice: String) = !choice.isEmpty && choice.forall(_.isDigit) && choice.toInt < steps.size\n+\n+    while (true) {\n+      println(\"------------------------------------\")\n+      println(\"Menu: \")\n+\n+      steps.zipWithIndex.foreach {\n+        case (step, i) => println(s\"  $i) ${step.description}\")\n+      }\n+\n+      println(\"  q) Quit\")\n+\n+      print(\"Choice: \")\n+      readLine().trim match {\n+        case \"q\" =>\n+          destroy()\n+          return\n+        case choice if validChoice(choice) =>\n+          try {\n+            steps(choice.toInt).execute()\n+          } catch {\n+            case t: Throwable => t.printStackTrace()\n+          }\n+        case _ =>\n+      }\n+    }\n+  }\n+\n+  /*\n+   * Code taken from Scala's \"App\" class. Reimplemented to execute menu","path":"commons-script/src/main/scala/com/wajam/script/Script.scala","position":75,"original_position":75,"commit_id":"f15c9cc347e0e32eacc6b9c5e733b8a87aeb7618","original_commit_id":"f15c9cc347e0e32eacc6b9c5e733b8a87aeb7618","user":{"login":"coderunner","id":408380,"avatar_url":"https://avatars.githubusercontent.com/u/408380?","gravatar_id":"dbf43a32d8321a36cf6e0e5fa9e53ccc","url":"https://api.github.com/users/coderunner","html_url":"https://github.com/coderunner","followers_url":"https://api.github.com/users/coderunner/followers","following_url":"https://api.github.com/users/coderunner/following{/other_user}","gists_url":"https://api.github.com/users/coderunner/gists{/gist_id}","starred_url":"https://api.github.com/users/coderunner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coderunner/subscriptions","organizations_url":"https://api.github.com/users/coderunner/orgs","repos_url":"https://api.github.com/users/coderunner/repos","events_url":"https://api.github.com/users/coderunner/events{/privacy}","received_events_url":"https://api.github.com/users/coderunner/received_events","type":"User","site_admin":false},"body":":sunglasses: Just bought suhailinda.club!","created_at":"2014-05-27T19:16:38Z","updated_at":"2014-05-27T19:16:38Z","html_url":"https://github.com/wajam/scala-commons/pull/54#discussion_r13096388","pull_request_url":"https://api.github.com/repos/wajam/scala-commons/pulls/54","_links":{"self":{"href":"https://api.github.com/repos/wajam/scala-commons/pulls/comments/13096388"},"html":{"href":"https://github.com/wajam/scala-commons/pull/54#discussion_r13096388"},"pull_request":{"href":"https://api.github.com/repos/wajam/scala-commons/pulls/54"}}}}