From ca672ddefa5f5929e78aa6647a1a33732f788bf0 Mon Sep 17 00:00:00 2001 From: Rhiannon Morris Date: Mon, 13 Jul 2020 05:00:46 +0200 Subject: [PATCH] change command line args for 'gallery' --- make-pages/Main.hs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/make-pages/Main.hs b/make-pages/Main.hs index adb830e..bf52cbd 100644 --- a/make-pages/Main.hs +++ b/make-pages/Main.hs @@ -16,10 +16,9 @@ data Options = copyImages :: Bool } | GalleryPage { - directory :: FilePath, + files :: [FilePath], includeNsfw :: Bool, - output :: Maybe FilePath, - single :: Bool + output :: Maybe FilePath } deriving Show @@ -28,14 +27,14 @@ optionsParser = (Opt.hsubparser (single <> gallery) <**> Opt.helper) `Opt.info` mainInfo where single = Opt.command "single" $ singleOpts `Opt.info` singleInfo - singleOpts = SinglePage <$> fileArg <*> nsfwSwitch <*> outputOpt <*> copyOpt + singleOpts = SinglePage <$> fileArg <*> nsfwSwitchS <*> outputOpt <*> copyOpt fileArg = Opt.strArgument $ Opt.metavar "FILE" <> Opt.help "yaml file to read" - nsfwSwitch = Opt.switch $ + nsfwSwitchS = Opt.switch $ Opt.short 'n' <> Opt.long "nsfw" <> Opt.help "include nsfw versions" outputOpt = Opt.option (Just <$> Opt.str) $ - Opt.short 'o' <> Opt.long "output" <> + Opt.short 'o' <> Opt.long "output" <> Opt.metavar "FILE" <> Opt.value Nothing <> Opt.help "output file (default: stdout)" copyOpt = Opt.switch $ @@ -44,13 +43,12 @@ optionsParser = singleInfo = Opt.progDesc "generate a page for a single work" gallery = Opt.command "gallery" $ galleryOpts `Opt.info` galleryInfo - galleryOpts = - GalleryPage <$> dirArg <*> nsfwSwitch <*> outputOpt <*> singleOpt - dirArg = Opt.strArgument $ - Opt.metavar "DIR" <> Opt.help "directory to search for yaml files" - singleOpt = fmap not $ Opt.switch $ - Opt.short 'S' <> Opt.long "exclude-single" <> - Opt.help "do not generate single pages" + galleryOpts = GalleryPage <$> filesArg <*> nsfwSwitchG <*> outputOpt + filesArg = many $ Opt.strArgument $ + Opt.metavar "FILE..." <> Opt.help "yaml files to read" + nsfwSwitchG = Opt.switch $ + Opt.short 'n' <> Opt.long "nsfw" <> + Opt.help "include works with only nsfw versions" galleryInfo = Opt.progDesc "generate a gallery page" mainInfo = Opt.progDesc "static gallery site generator" <> Opt.fullDesc