aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/app/Main.hs60
-rw-r--r--compiler/package.yaml2
2 files changed, 27 insertions, 35 deletions
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index d9b019a..1773073 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.hs
@@ -17,50 +17,42 @@
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 RecordWildCards 20 DeriveDataTypeable
21 , ApplicativeDo
22#-} 21#-}
23 22
24module Main where 23module Main where
25 24
26import Options.Applicative 25import Paths_ldgallery_compiler (version)
27import Data.Semigroup ((<>)) 26import Data.Version (showVersion)
27import System.Console.CmdArgs
28import Compiler 28import Compiler
29 29
30data Args = Args 30
31data Options = Options
31 { inputDir :: String 32 { inputDir :: String
32 , outputDir :: String 33 , outputDir :: String
33 , rebuild :: Bool } 34 , rebuild :: Bool
35 } deriving (Show, Data, Typeable)
36
37options = Options
38 { inputDir = "./"
39 &= typDir
40 &= help "Gallery source directory (default=./)"
41 , outputDir = "./out"
42 &= typDir
43 &= help "Generated gallery output path (default=./out)"
44 , rebuild = False
45 &= help "Invalidate cache and recompile everything"
46 }
47 &= summary ("ldgallery v" ++ (showVersion version) ++ " - a static gallery generator with tags")
48 &= program "ldgallery"
49 &= help "Compile a gallery"
50 &= helpArg [explicit, name "h", name "help"]
51 &= versionArg [explicit, name "v", name "version"]
34 52
35args :: Parser Args
36args = Args
37 <$> strOption
38 ( long "input"
39 <> short 'i'
40 <> metavar "SOURCE DIR"
41 <> value "./"
42 <> showDefault
43 <> help "Gallery source directory" )
44 <*> strOption
45 ( long "output"
46 <> short 'o'
47 <> metavar "OUTPUT DIR"
48 <> value "./out"
49 <> showDefault
50 <> help "Generated gallery output path" )
51 <*> switch
52 ( long "rebuild"
53 <> short 'r'
54 <> help "Invalidate cache and recompile everything" )
55 53
56main :: IO () 54main :: IO ()
57main = 55main =
58 do 56 do
59 options <- execParser opts 57 opts <- cmdArgs options
60 compileGallery (inputDir options) (outputDir options) (rebuild options) 58 compileGallery (inputDir opts) (outputDir opts) (rebuild opts)
61
62 where
63 opts = info (args <**> helper)
64 ( fullDesc
65 <> progDesc "Compile a gallery"
66 <> header "ldgallery - a static gallery generator with tags" )
diff --git a/compiler/package.yaml b/compiler/package.yaml
index b594ee7..21677fb 100644
--- a/compiler/package.yaml
+++ b/compiler/package.yaml
@@ -22,7 +22,7 @@ dependencies:
22- text 22- text
23- aeson 23- aeson
24- yaml 24- yaml
25- optparse-applicative 25- cmdargs
26- JuicyPixels 26- JuicyPixels
27- JuicyPixels-extra 27- JuicyPixels-extra
28 28