module Git.Fmt.Options.Applicative.Parser (
gitFmtPrefs, gitFmtInfo, gitFmt,
) where
import Data.List (nub)
import Data.Version (showVersion)
import Options.Applicative
import Git.Fmt
import Git.Fmt.Version as This
gitFmtPrefs :: ParserPrefs
gitFmtPrefs = prefs $ columns 100
gitFmtInfo :: ParserInfo Options
gitFmtInfo = info (infoOptions <*> gitFmt) fullDesc
where
infoOptions = helper <*> version <*> numericVersion
version = infoOption ("Version " ++ showVersion This.version) $ mconcat [
long "version", short 'V', hidden,
help "Show this binary's version"
]
numericVersion = infoOption (showVersion This.version) $ mconcat [
long "numeric-version", hidden,
help "Show this binary's version (without the prefix)"
]
gitFmt :: Parser Options
gitFmt = Options
<$> switch (mconcat [
long "quiet", short 'q',
help "Be quiet"
])
<*> switch (mconcat [
long "verbose", short 'v',
help "Be verbose"
])
<*> switch (mconcat [
long "dry-run", short 'n',
help "Doesn't perform any writes (useful with --list-ugly)"
])
<*> switch (mconcat [
long "list-ugly", short 'l',
help "List all ugly files formatted"
])
<*> fmap nub (many $ strArgument (mconcat [
metavar "-- FILES..."
]))