aboutsummaryrefslogtreecommitdiff
path: root/tea-cleaner/TeaCleaner/CommandLine.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2025-01-26 10:17:33 +0100
committerEugen Wissner <belka@caraus.de>2025-01-26 10:17:33 +0100
commit6c170513a69bd4c49b006d0672637a48eb449884 (patch)
tree617403177519fec8312502c40bf3e3bc98b9c48d /tea-cleaner/TeaCleaner/CommandLine.hs
parent3c430bca64c813a0a04cb98d5cd9a3d3fb70e1b0 (diff)
downloadkazbek-6c170513a69bd4c49b006d0672637a48eb449884.tar.gz
tea-cleaner: Add command line parser
Diffstat (limited to 'tea-cleaner/TeaCleaner/CommandLine.hs')
-rw-r--r--tea-cleaner/TeaCleaner/CommandLine.hs45
1 files changed, 45 insertions, 0 deletions
diff --git a/tea-cleaner/TeaCleaner/CommandLine.hs b/tea-cleaner/TeaCleaner/CommandLine.hs
new file mode 100644
index 0000000..b74263d
--- /dev/null
+++ b/tea-cleaner/TeaCleaner/CommandLine.hs
@@ -0,0 +1,45 @@
+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"