diff options
Diffstat (limited to 'src/Main.hs')
| -rw-r--r-- | src/Main.hs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/Main.hs b/src/Main.hs index 0b67b5d..848d992 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -6,6 +6,7 @@ import Data.Char (isNumber) import Control.Applicative (Applicative(liftA2)) import Data.List.NonEmpty (NonEmpty(..)) import qualified Data.List.NonEmpty as NonEmpty +import Control.Monad.Catch (MonadThrow(..)) import Control.Monad.IO.Class (MonadIO(..)) import Data.Maybe (fromJust) import qualified Data.Map as Map @@ -250,8 +251,13 @@ autoUpdatable = } ] -up2Date :: SlackBuilderT () -up2Date = for_ autoUpdatable go +up2Date :: Maybe Text -> SlackBuilderT () +up2Date = \case + Nothing -> for_ autoUpdatable go + Just packageName + | Just foundPackage <- find ((packageName ==) . getField @"name") autoUpdatable -> + go foundPackage + | otherwise -> throwM $ UpdaterNotFound packageName where go package = getAndLogLatest package >>= mapM_ (updatePackageIfRequired package) @@ -427,10 +433,10 @@ main = do maybe (pure ()) Text.IO.putStrLn latestVersion where executeCommand = \case - CategoryCommand _packageName -> do + CategoryCommand -> do repository' <- SlackBuilderT $ asks repository categories <- liftIO $ findCategory repository' liftIO $ print $ splitFileName . makeRelative repository' <$> categories pure Nothing CheckCommand -> check >> pure Nothing - Up2DateCommand -> up2Date >> pure Nothing + Up2DateCommand packageName -> up2Date packageName >> pure Nothing |
