diff options
| author | Teddy Wing | 2017-08-20 20:38:52 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-08-20 20:40:56 +0200 | 
| commit | 0b20b2b113e68396a8ab4e6b59b349dc9248d85b (patch) | |
| tree | 828d6b4e6ee5988f688b62fc426601da2b7352c1 /src/Plugin | |
| parent | 37c39d1267e6211233a98081ddea9fef2a6f05df (diff) | |
| download | sorbot-0b20b2b113e68396a8ab4e6b59b349dc9248d85b.tar.bz2 | |
GitHubCommit: Extract language handling to a function
Move the CLI option extracting to a new function that moves the option
parsing logic outside the plugin.
Diffstat (limited to 'src/Plugin')
| -rw-r--r-- | src/Plugin/GitHubCommit.hs | 19 | 
1 files changed, 7 insertions, 12 deletions
| diff --git a/src/Plugin/GitHubCommit.hs b/src/Plugin/GitHubCommit.hs index b8ecf9e..74658a9 100644 --- a/src/Plugin/GitHubCommit.hs +++ b/src/Plugin/GitHubCommit.hs @@ -12,7 +12,7 @@ import Text.Regex.TDFA  import I18n  import qualified Message as M -import CliOptions (Options(language), parseOptions) +import qualified CliOptions as Cli (lang)  import Plugin.Base  gitHubCommit = defaultPlugin @@ -33,20 +33,15 @@ gitHubCommitAction message = do          :: IO [RepoUrlRow]      close dbConn -    opts <- parseOptions -    let lang = language opts - -    return $ respond rs lang +    respond rs    where -    respond [] lang = -        Left $ translate lang GitHubCommitRepoURLNotFound -    respond ((RepoUrlRow r):_) _ = -        Right $ r `T.append` "/commits/" `T.append` T.pack ( +    respond [] = do +        lang <- Cli.lang +        return $ Left $ translate lang GitHubCommitRepoURLNotFound +    respond ((RepoUrlRow r):_) = +        return $ Right $ r `T.append` "/commits/" `T.append` T.pack (              M.textStr message =~ matchRegex gitHubCommit) --- TODO --- lang ::  -  type Id = Int  type RepoUrl = T.Text | 
