about summary refs log tree commit diff
path: root/tools
diff options
context:
space:
mode:
authorVincent Ambo <v.ambo@me.com>2012-03-25T17·01+0200
committerVincent Ambo <v.ambo@me.com>2012-03-25T17·01+0200
commit74ce7d9bf0c837b89c48579b6c97dac3ce042093 (patch)
tree33f27d2d5822d5542fc24ec712d8e626e44b6adc /tools
parent7f4761bf7c25d9c99e8ef329678ce20f4026ba75 (diff)
* small colouriser tool to run .hs files through HsColour
Diffstat (limited to 'tools')
-rw-r--r--tools/colouriser/LICENSE3
-rw-r--r--tools/colouriser/colour.cabal64
-rw-r--r--tools/colouriser/colour.hs21
3 files changed, 88 insertions, 0 deletions
diff --git a/tools/colouriser/LICENSE b/tools/colouriser/LICENSE
new file mode 100644
index 000000000000..44ade8735185
--- /dev/null
+++ b/tools/colouriser/LICENSE
@@ -0,0 +1,3 @@
+This program comes with absolutely no warranty and I can't guarantee that it's not going to explode in your face.
+
+In addition to this, I don't care what you do with this.
\ No newline at end of file
diff --git a/tools/colouriser/colour.cabal b/tools/colouriser/colour.cabal
new file mode 100644
index 000000000000..c74e6f2da868
--- /dev/null
+++ b/tools/colouriser/colour.cabal
@@ -0,0 +1,64 @@
+-- colour.cabal auto-generated by cabal init. For additional options,
+-- see
+-- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr.
+-- The name of the package.
+Name:                colour
+
+-- The package version. See the Haskell package versioning policy
+-- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for
+-- standards guiding when and how versions should be incremented.
+Version:             0.1
+
+-- A short (one-line) description of the package.
+Synopsis:            Shortcut program to use HsColour
+
+-- A longer description of the package.
+-- Description:         
+
+-- URL for the project homepage or repository.
+Homepage:            http://tazj.in/
+
+-- The license under which the package is released.
+License:             OtherLicense
+
+-- The file containing the license text.
+License-file:        LICENSE
+
+-- The package author(s).
+Author:              tazjin
+
+-- An email address to which users can send suggestions, bug reports,
+-- and patches.
+-- Maintainer:          
+
+-- A copyright notice.
+-- Copyright:           
+
+Category:            Web
+
+Build-type:          Simple
+
+-- Extra files to be distributed with the package, such as examples or
+-- a README.
+-- Extra-source-files:  
+
+-- Constraint on the version of Cabal needed to build this package.
+Cabal-version:       >=1.2
+
+
+Executable colour
+  -- .hs or .lhs file containing the Main module.
+  Main-is: colour.hs            
+  
+  -- Packages needed in order to build this package.
+  Build-depends:
+    base,
+    options,
+    hscolour       
+  
+  -- Modules not exported by this package.
+  -- Other-modules:       
+  
+  -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.
+  -- Build-tools:         
+  
\ No newline at end of file
diff --git a/tools/colouriser/colour.hs b/tools/colouriser/colour.hs
new file mode 100644
index 000000000000..03ae8d51f4e0
--- /dev/null
+++ b/tools/colouriser/colour.hs
@@ -0,0 +1,21 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+import Control.Monad (unless)
+import Language.Haskell.HsColour.Colourise (defaultColourPrefs)
+import Language.Haskell.HsColour.CSS
+import Options
+
+defineOptions "MainOptions" $ do
+	stringOption "optFile" "file" ""
+		"Name of the .hs file. Will be used for the HTML file as well"
+
+colorCode :: String -> String -> IO ()
+colorCode input output = do
+	code <- readFile input
+	writeFile output $ hscolour False code
+
+main :: IO ()
+main = runCommand $ \opts args -> do
+	let file = optFile opts
+	unless (file == "") $
+		colorCode (file ++ ".hs") (file ++ ".html")
\ No newline at end of file