option to list tags by name

This commit is contained in:
Rhiannon Morris 2021-03-07 20:51:44 +01:00
parent da23a052f0
commit c1d588f702
3 changed files with 22 additions and 8 deletions

View file

@ -60,10 +60,13 @@ data ModeOptions =
dataDir :: FilePath,
infoName :: FilePath,
nsfw :: Bool,
listUntagged :: Bool
listUntagged :: Bool,
sortBy :: TagSort
}
deriving Show
data TagSort = SortFreq | SortName deriving Show
optionsParser :: ParserInfo Options
optionsParser = globalOpts `info` mainInfo where
@ -142,13 +145,18 @@ optionsParser = globalOpts `info` mainInfo where
dgInfo = progDesc "generate makefile dependencies for a gallery"
listTags = command "list-tags" $ ltOpts `info` ltInfo
ltOpts = ListTags <$> dataDir <*> infoName <*> nsfwT <*> listUntagged_
ltOpts = ListTags <$> dataDir <*> infoName <*> nsfwT
<*> listUntagged_ <*> listSort
nsfwT = switch $
short 'n' <> long "nsfw" <>
help "include nsfw tags"
listUntagged_ = switch $
short 'U' <> long "untagged" <>
help "list files with no tags"
listSort = fmap toSort $ switch $
short 'a' <> long "alpha" <>
help "sort alphabetically instead of by frequency"
where toSort x = if x then SortName else SortFreq
ltInfo = progDesc "list all tags used by frequency"
mainInfo = progDesc "static gallery site generator" <> fullDesc