aboutsummaryrefslogtreecommitdiff
path: root/compiler/app
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/app')
-rw-r--r--compiler/app/Main.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index 061fab7..e71e0db 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.hs
@@ -21,6 +21,7 @@ module Main where
21import GHC.Generics (Generic) 21import GHC.Generics (Generic)
22import Paths_ldgallery_compiler (version, getDataFileName) 22import Paths_ldgallery_compiler (version, getDataFileName)
23import Control.Monad (when) 23import Control.Monad (when)
24import Data.Functor ((<&>))
24import Data.Maybe (isJust) 25import Data.Maybe (isJust)
25import Data.Version (showVersion) 26import Data.Version (showVersion)
26import Data.Aeson (ToJSON) 27import Data.Aeson (ToJSON)
@@ -32,7 +33,7 @@ import Compiler
32import Files (readDirectory, copyTo, remove) 33import Files (readDirectory, copyTo, remove)
33 34
34 35
35data ViewerConfig = ViewerConfig 36newtype ViewerConfig = ViewerConfig
36 { galleryRoot :: String 37 { galleryRoot :: String
37 } deriving (Generic, Show, ToJSON) 38 } deriving (Generic, Show, ToJSON)
38 39
@@ -92,7 +93,7 @@ options = Options
92 &= help "Deploy either the bundled or the given static web viewer to the output directory" 93 &= help "Deploy either the bundled or the given static web viewer to the output directory"
93 } 94 }
94 95
95 &= summary ("ldgallery v" ++ (showVersion version) ++ " - a static web gallery generator with tags") 96 &= summary ("ldgallery v" ++ showVersion version ++ " - a static web gallery generator with tags")
96 &= program "ldgallery" 97 &= program "ldgallery"
97 &= help "Compile a gallery" 98 &= help "Compile a gallery"
98 &= helpArg [explicit, name "h", name "help"] 99 &= helpArg [explicit, name "h", name "help"]
@@ -146,7 +147,7 @@ main =
146 147
147 deployViewer :: FilePath -> Options -> IO () 148 deployViewer :: FilePath -> Options -> IO ()
148 deployViewer distPath Options{outputDir, cleanOutput} = 149 deployViewer distPath Options{outputDir, cleanOutput} =
149 (when cleanOutput $ cleanViewerDir outputDir) 150 when cleanOutput (cleanViewerDir outputDir)
150 >> copyViewer distPath outputDir 151 >> copyViewer distPath outputDir
151 >> writeJSON (outputDir </> "config.json") viewerConfig 152 >> writeJSON (outputDir </> "config.json") viewerConfig
152 153
@@ -154,8 +155,8 @@ main =
154 cleanViewerDir :: FilePath -> IO () 155 cleanViewerDir :: FilePath -> IO ()
155 cleanViewerDir target = 156 cleanViewerDir target =
156 listDirectory target 157 listDirectory target
157 >>= return . filter (/= gallerySubdir) 158 <&> filter (/= gallerySubdir)
158 >>= mapM_ remove . map (target </>) 159 >>= mapM_ (remove . (target </>))
159 160
160 copyViewer :: FilePath -> FilePath -> IO () 161 copyViewer :: FilePath -> FilePath -> IO ()
161 copyViewer dist target = 162 copyViewer dist target =