about summary refs log tree commit diff
path: root/tools/colouriser/colour.hs
blob: 03ae8d51f4e055c3ddb9bb333f2eee8f067fba00 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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")