3 // BlackQuill Copyright (C) 2013 set.minami<set,minami@gmail.com>
4 // Lisence MIT see also LISENCE.txt
5 // Main object and set Switches.
7 import scala.collection.JavaConversions._
8 import scala.util.matching._
12 val lastDate = "May 14 2013"
14 val wiki = "https://github.com/setminami/BlackQuill/wiki/"
15 val syntax = "BlackQuill-Details-of-Syntax"
16 val philosophy = "BlackQuill-Philosophy"
19 "--force|-f : Force conversion. BQ ignore timestamps of markdown files.\n" +
20 "--stdout|-s :BQ outputs document to STDOUT as HTML.\n" +
21 "--enc shift-jis|euc-jp|UTF-8|ASCII default input enc is UTF-8\n" +
22 "- : BQ accept markdown document from STDIN\n" +
23 "--output DIR|-o :BQ outputs HTML to under DIR\n" +
24 "--verbose|-v :output conversion processes verbosely \n" +
25 "--version :output version and so on.\n" +
26 "--help|-h :output usage descriptions\n" +
27 "...and Markdown file's suffix is .md|.markdown|.txt|.bq|.BlackQuill\n" +
28 "e.g., BlackQuill --force foo.md"
31 val description = "Welcome to BlackQuill.\n" +
32 "BQ switches=> \n" + options +
33 "Please see also... \n" +
34 wiki + syntax + "\n" +
35 wiki + philosophy + "\n"
38 def setInputfile(input:String){inputFile = input}
39 def getInputfile{inputFile}
41 def setForce(b:Boolean){force = b}
43 def setStdout(b:Boolean){stdout = b}
45 def setStdin(b:Boolean){stdin = b}
47 def setOutput(b:Boolean,dir:String){output = b;dirName = dir}
49 def getOutputDir{dirName}
50 def setVerbose(b:Boolean){verbose = b}
51 def getVerbose{verbose}
52 def setEncoding(b:Boolean,enc:String){encFlag=b;encode = enc}
53 def getEncoding{encode}
72 def main(args:Array[String]){
74 val f : Regex = """(.+)\s(.+)""".r
75 val sufRegex = """(\.md$)|(\.markdown$)|(\.txt$)|(\.bq$)|(\.blackquill$)""".r
81 case "--force"|"-f" => Switches.setForce(true)
82 case "--stdout"|"-s" => Switches.setStdout(true)
83 case f("--enc",v) => Switches.setEncoding(true,v)
84 case f("--output",v) => Switches.setOutput(true,v)
85 case "--verbose"|"-v" => Switches.setVerbose(true)
86 case "--version" => println("BlackQuill Version" + VERSION + " updated at " + lastDate)
90 if(sufRegex.findFirstIn(s) != None){
91 Switches.setInputfile(s)
93 throw new RuntimeException
97 }catch{ case e:Exception => println("wrong switch is found see --help or Website\n" + wiki)}