slackbuilder/app/Main.hs

29 lines
884 B
Haskell

module Main
( main
) where
import qualified Data.Text.IO as Text.IO
import Data.Maybe (fromMaybe)
import Options.Applicative (execParser)
import SlackBuilder.CommandLine
import SlackBuilder.Config
import SlackBuilder.Updater
import qualified Toml
import qualified Data.Text as Text
main :: IO ()
main = do
programCommand <- execParser slackBuilderParser
settings <- Toml.decodeFile settingsCodec "config/config.toml"
latestVersion <- case programCommand of
PackagistCommand packagistArguments ->
latestPackagist packagistArguments
TextCommand textArguments -> latestText textArguments
GhCommand ghArguments -> latestGitHub settings ghArguments (stripPrefix "v")
Text.IO.putStrLn $ fromMaybe "" latestVersion
where
stripPrefix prefix string = Just
$ fromMaybe string
$ Text.stripPrefix prefix string