From c3f1d45743e274f588e5a23ba25e1fc124728c11 Mon Sep 17 00:00:00 2001 From: pacien Date: Fri, 27 Dec 2019 11:07:58 +0100 Subject: compiler: add command line interface --- compiler/app/Main.hs | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'compiler/app/Main.hs') diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs index 2511998..be57c82 100644 --- a/compiler/app/Main.hs +++ b/compiler/app/Main.hs @@ -17,14 +17,41 @@ -- along with this program. If not, see . {-# LANGUAGE - DuplicateRecordFields - , DeriveGeneric - , DeriveAnyClass + RecordWildCards + , ApplicativeDo #-} module Main where +import Options.Applicative +import Data.Semigroup ((<>)) import Compiler +data Args = Args + { inputDir :: String + , outputDir :: String } + +args :: Parser Args +args = Args + <$> strOption + ( long "input" + <> short 'i' + <> metavar "INPUT DIR" + <> help "Gallery source directory" ) + <*> strOption + ( long "output" + <> short 'o' + <> metavar "OUTPUT DIR" + <> help "Generated gallery output path, outside of the input directory" ) + main :: IO () -main = compileGallery "../../example" "../../out" +main = + do + options <- execParser opts + compileGallery (inputDir options) (outputDir options) + + where + opts = info (args <**> helper) + ( fullDesc + <> progDesc "Compile a picture gallery" + <> header "ldgallery - A static generator which turns a collection of tagged pictures into a searchable web gallery.") -- cgit v1.2.3