diff options
Diffstat (limited to 'compiler/app/Main.hs')
-rw-r--r-- | compiler/app/Main.hs | 11 |
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 | |||
21 | import GHC.Generics (Generic) | 21 | import GHC.Generics (Generic) |
22 | import Paths_ldgallery_compiler (version, getDataFileName) | 22 | import Paths_ldgallery_compiler (version, getDataFileName) |
23 | import Control.Monad (when) | 23 | import Control.Monad (when) |
24 | import Data.Functor ((<&>)) | ||
24 | import Data.Maybe (isJust) | 25 | import Data.Maybe (isJust) |
25 | import Data.Version (showVersion) | 26 | import Data.Version (showVersion) |
26 | import Data.Aeson (ToJSON) | 27 | import Data.Aeson (ToJSON) |
@@ -32,7 +33,7 @@ import Compiler | |||
32 | import Files (readDirectory, copyTo, remove) | 33 | import Files (readDirectory, copyTo, remove) |
33 | 34 | ||
34 | 35 | ||
35 | data ViewerConfig = ViewerConfig | 36 | newtype 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 = |