diff options
author | Teddy Wing | 2017-08-19 18:44:56 +0200 |
---|---|---|
committer | Teddy Wing | 2017-08-19 18:50:54 +0200 |
commit | 1884f2e54097bdce9a4a011065a89044c86a8ebf (patch) | |
tree | 5f378ce3e6ccc929837bc1e99c35cc88804fedb9 /src/CliOptions.hs | |
parent | 54f23f1d77a3623d6e18c0a55b622d4cfab60406 (diff) | |
download | sorbot-1884f2e54097bdce9a4a011065a89044c86a8ebf.tar.bz2 |
Add command line option handling
Use 'optparse-applicative' to parse command line options.
Provide a `--slack-token` option that sets a Slack API token to enable
access to the chat platform.
More options will come as needed (including things like database name,
language, possibly IRC configuration).
Code is based on the example in
https://hackage.haskell.org/package/optparse-applicative
Pretty cool option parser.
Diffstat (limited to 'src/CliOptions.hs')
-rw-r--r-- | src/CliOptions.hs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/CliOptions.hs b/src/CliOptions.hs new file mode 100644 index 0000000..861f48e --- /dev/null +++ b/src/CliOptions.hs @@ -0,0 +1,28 @@ +module CliOptions + ( parseOptions + ) where + +import Data.Semigroup ((<>)) +import Options.Applicative + +data Options = Options + { slackApiToken :: String + } + +options :: Parser Options +options = Options + <$> strOption + ( long "slack-token" + <> metavar "TOKEN" + <> value "" + <> help "Token to access Slack's real-time messaging API" ) + +parseOptions :: IO () +parseOptions = do + execParser opts + return () + where + opts = info (options <**> helper) + ( fullDesc + <> progDesc "A chat bot with a plugin interface that does a bunch of \ + \random things." ) |