2023-08-04 21:33:21 +02:00
|
|
|
module Main
|
|
|
|
( main
|
|
|
|
) where
|
|
|
|
|
|
|
|
import qualified Data.Text.IO as Text.IO
|
|
|
|
import Data.Maybe (fromMaybe)
|
2023-08-06 14:25:19 +02:00
|
|
|
import Options.Applicative (execParser)
|
|
|
|
import SlackBuilder.CommandLine
|
2023-08-09 20:59:42 +02:00
|
|
|
import SlackBuilder.Config
|
2023-08-06 14:25:19 +02:00
|
|
|
import SlackBuilder.Updater
|
2023-08-09 20:59:42 +02:00
|
|
|
import qualified Toml
|
|
|
|
import qualified Data.Text as Text
|
2023-08-04 21:33:21 +02:00
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = do
|
2023-08-06 14:25:19 +02:00
|
|
|
programCommand <- execParser slackBuilderParser
|
2023-08-09 20:59:42 +02:00
|
|
|
settings <- Toml.decodeFile settingsCodec "config/config.toml"
|
2023-08-06 14:25:19 +02:00
|
|
|
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")
|
2023-08-04 21:33:21 +02:00
|
|
|
|
2023-08-06 14:25:19 +02:00
|
|
|
Text.IO.putStrLn $ fromMaybe "" latestVersion
|
2023-08-09 20:59:42 +02:00
|
|
|
where
|
|
|
|
stripPrefix prefix string = Just
|
|
|
|
$ fromMaybe string
|
|
|
|
$ Text.stripPrefix prefix string
|