slackbuilder/app/Main.hs

29 lines
884 B
Haskell
Raw Normal View History

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