46 lines
1.0 KiB
Haskell
46 lines
1.0 KiB
Haskell
|
module TeaCleaner.CommandLine
|
||
|
( ProgramOptions(..)
|
||
|
, commandLineInfo
|
||
|
, execParser
|
||
|
) where
|
||
|
|
||
|
import Data.Text (Text)
|
||
|
import Options.Applicative
|
||
|
( Parser
|
||
|
, ParserInfo
|
||
|
, (<**>)
|
||
|
, argument
|
||
|
, execParser
|
||
|
, fullDesc
|
||
|
, help
|
||
|
, helper
|
||
|
, info
|
||
|
, long
|
||
|
, metavar
|
||
|
, progDesc
|
||
|
, str
|
||
|
, switch
|
||
|
)
|
||
|
|
||
|
data ProgramOptions = ProgramOptions
|
||
|
{ server :: Text
|
||
|
, token :: Text
|
||
|
, liveRun :: Bool
|
||
|
} deriving (Eq, Show)
|
||
|
|
||
|
commandLineInfo :: ParserInfo ProgramOptions
|
||
|
commandLineInfo = info (commandLine <**> helper)
|
||
|
$ fullDesc <> progDesc "Helps to detect some spam gitea accounts"
|
||
|
|
||
|
commandLine :: Parser ProgramOptions
|
||
|
commandLine = ProgramOptions
|
||
|
<$> serverOption
|
||
|
<*> tokenOption
|
||
|
<*> liveRunOption
|
||
|
where
|
||
|
serverOption = argument str
|
||
|
$ metavar "SERVER" <> help "Gitea server URL"
|
||
|
tokenOption = argument str
|
||
|
$ metavar "TOKEN" <> help "Access token"
|
||
|
liveRunOption = switch $ long "live-run" <> help "Purge suspicious users"
|