lentil-1.0.2.0: src/Main.hs
import Lentil.Types
import Lentil.Args
import Lentil.File
import Lentil.Print
import Lentil.Query
import Lentil.Export
import Options.Applicative
import qualified Data.Maybe as M
import Data.Monoid -- 7.8
import qualified System.IO as I
main :: IO ()
main = I.hSetBuffering I.stderr I.NoBuffering >> -- b/c progress bar
execParser opts >>= runLentil
where opts = info (helpOvert <*> lOpts <* version)
( fullDesc <>
header "lentil - frugal issue tracker" )
-- overt help text (even in condensed help)
helpOvert :: Parser (a -> a)
helpOvert = abortOption ShowHelpText $ mconcat [ long "help",
short 'h',
help "Show this help text" ]
version = infoOption versionCopy ( long "version" <>
short 'v' <>
help "show version and copyright info" )
where
versionCopy = "\nlentil - frugal issue tracker, version 1.0.2.0\n\
\(C) 2015-2016 Francesco Ariis - http://www.ariis.it\n\
\released under the GNU General Public License v3\n"
runLentil :: LOptions -> IO ()
runLentil lo = uncurry (findIssues (loAlias lo) (loFlagwords lo))
(loInExcl lo) >>= \is -> -- grab issues
let fil = filterAnd (loFilters lo) is -- filtered
-- ord = chainSorts fil (loSort lo) -- ordered
-- todo leave sort out as now? [design]
-- which function to use to output stuff (file/term)
outFunction :: String -> IO ()
outFunction = case loOutFile lo of
Nothing -> putStrLn
Just fp -> writeFile fp
-- col or not?
bCol :: Bool
bCol = if loOutFile lo == Nothing
then True
else False
in
case loFormat lo of
Pretty -> outFunction (ppIssues bCol fil) -- fixme o ord?
TagPop -> outFunction (ppPopularity bCol fil)
Csv -> outFunction (issues2CSV fil)
Comp -> outFunction (issues2Compiler fil)
Xml -> outFunction (issues2Xml fil)