From 17998a5e8d386b58d30d138ea8dbc565955cccc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 11 Jan 2025 19:33:54 +0100 Subject: Concurrently run jobs for multiple commits Changelog: Concurrently run jobs for multiple commits --- src/Command.hs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/Command.hs') diff --git a/src/Command.hs b/src/Command.hs index 2c2235f..c602ba8 100644 --- a/src/Command.hs +++ b/src/Command.hs @@ -6,8 +6,10 @@ module Command ( CommandArgumentsType(..), CommandExec(..), + CommandInput(..), getCommonOptions, getConfig, + getTerminalOutput, ) where import Control.Monad.Except @@ -20,6 +22,7 @@ import Data.Text qualified as T import System.Console.GetOpt import Config +import Terminal data CommonOptions = CommonOptions { optJobs :: Int @@ -67,11 +70,20 @@ instance CommandArgumentsType (Maybe Text) where argsFromStrings _ = throwError "expected at most one argument" -newtype CommandExec a = CommandExec (ReaderT ( CommonOptions, Config ) IO a) +newtype CommandExec a = CommandExec (ReaderT CommandInput IO a) deriving (Functor, Applicative, Monad, MonadIO) +data CommandInput = CommandInput + { ciOptions :: CommonOptions + , ciConfig :: Config + , ciTerminalOutput :: TerminalOutput + } + getCommonOptions :: CommandExec CommonOptions -getCommonOptions = CommandExec (asks fst) +getCommonOptions = CommandExec (asks ciOptions) getConfig :: CommandExec Config -getConfig = CommandExec (asks snd) +getConfig = CommandExec (asks ciConfig) + +getTerminalOutput :: CommandExec TerminalOutput +getTerminalOutput = CommandExec (asks ciTerminalOutput) -- cgit v1.2.3