From 15c806adec22239096a910b92b49fcfb964815bd Mon Sep 17 00:00:00 2001 From: pacien Date: Thu, 30 Jan 2020 17:01:15 +0100 Subject: compiler: add flag for output dir cleanup Making it explicit. GitHub: closes #62 --- compiler/app/Main.hs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'compiler/app') diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs index 1a42abf..4dd6660 100644 --- a/compiler/app/Main.hs +++ b/compiler/app/Main.hs @@ -31,6 +31,7 @@ data Options = Options { inputDir :: String , outputDir :: String , rebuilAll :: Bool + , cleanOutput :: Bool , withViewer :: Bool } deriving (Show, Data, Typeable) @@ -53,6 +54,11 @@ options = Options &= name "rebuild-all" &= explicit &= help "Invalidate cache and recompile everything" + , cleanOutput = False + &= name "c" + &= name "clean-output" + &= explicit + &= help "Remove unnecessary files from the output directory" , withViewer = False &= name "w" &= name "with-viewer" @@ -71,10 +77,23 @@ main :: IO () main = do opts <- cmdArgs options - compileGallery (inputDir opts) (galleryOutputDir "gallery" opts) (rebuilAll opts) - if (withViewer opts) then copyViewer (outputDir opts) else noop + + buildGallery opts + + if (withViewer opts) then + copyViewer (outputDir opts) + else + return () where + buildGallery :: Options -> IO () + buildGallery opts = + compileGallery + (inputDir opts) + (galleryOutputDir "gallery" opts) + (rebuilAll opts) + (cleanOutput opts) + galleryOutputDir :: FilePath -> Options -> FilePath galleryOutputDir gallerySubdir opts = if withViewer opts then outputBase gallerySubdir else outputBase @@ -86,6 +105,3 @@ main = >> getDataFileName "viewer" >>= readDirectory >>= copyTo target - - noop :: IO () - noop = return () -- cgit v1.2.3