diff options
author | pacien | 2019-12-27 11:07:58 +0100 |
---|---|---|
committer | pacien | 2019-12-27 11:07:58 +0100 |
commit | c3f1d45743e274f588e5a23ba25e1fc124728c11 (patch) | |
tree | 9e8717e06a2e355ad7eed7590ecc3e1b6292fabb /compiler/app | |
parent | 6bc29b5db2c8de62e2d9f21c25fa8dcd1ec5a75b (diff) | |
download | ldgallery-c3f1d45743e274f588e5a23ba25e1fc124728c11.tar.gz |
compiler: add command line interface
Diffstat (limited to 'compiler/app')
-rw-r--r-- | compiler/app/Main.hs | 35 |
1 files changed, 31 insertions, 4 deletions
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 @@ | |||
17 | -- along with this program. If not, see <https://www.gnu.org/licenses/>. | 17 | -- along with this program. If not, see <https://www.gnu.org/licenses/>. |
18 | 18 | ||
19 | {-# LANGUAGE | 19 | {-# LANGUAGE |
20 | DuplicateRecordFields | 20 | RecordWildCards |
21 | , DeriveGeneric | 21 | , ApplicativeDo |
22 | , DeriveAnyClass | ||
23 | #-} | 22 | #-} |
24 | 23 | ||
25 | module Main where | 24 | module Main where |
26 | 25 | ||
26 | import Options.Applicative | ||
27 | import Data.Semigroup ((<>)) | ||
27 | import Compiler | 28 | import Compiler |
28 | 29 | ||
30 | data Args = Args | ||
31 | { inputDir :: String | ||
32 | , outputDir :: String } | ||
33 | |||
34 | args :: Parser Args | ||
35 | args = Args | ||
36 | <$> strOption | ||
37 | ( long "input" | ||
38 | <> short 'i' | ||
39 | <> metavar "INPUT DIR" | ||
40 | <> help "Gallery source directory" ) | ||
41 | <*> strOption | ||
42 | ( long "output" | ||
43 | <> short 'o' | ||
44 | <> metavar "OUTPUT DIR" | ||
45 | <> help "Generated gallery output path, outside of the input directory" ) | ||
46 | |||
29 | main :: IO () | 47 | main :: IO () |
30 | main = compileGallery "../../example" "../../out" | 48 | main = |
49 | do | ||
50 | options <- execParser opts | ||
51 | compileGallery (inputDir options) (outputDir options) | ||
52 | |||
53 | where | ||
54 | opts = info (args <**> helper) | ||
55 | ( fullDesc | ||
56 | <> progDesc "Compile a picture gallery" | ||
57 | <> header "ldgallery - A static generator which turns a collection of tagged pictures into a searchable web gallery.") | ||