diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2025-01-10 22:21:14 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-01-10 22:21:14 +0100 |
commit | 654edd780dfd28b3611e42df9fd7fd68b8f88191 (patch) | |
tree | 01747437b15ad3740637fbdef986546e07fa8d1a /src/Command.hs | |
parent | ded067166901805bba63a35b37fe83ebfc4e6aa8 (diff) |
Limit number of concurrently running jobsdevel
Changelog: Configurable number of concurrently running jobs
Diffstat (limited to 'src/Command.hs')
-rw-r--r-- | src/Command.hs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/Command.hs b/src/Command.hs index 0ca6710..2c2235f 100644 --- a/src/Command.hs +++ b/src/Command.hs @@ -1,8 +1,12 @@ module Command ( + CommonOptions(..), + defaultCommonOptions, + Command(..), CommandArgumentsType(..), CommandExec(..), + getCommonOptions, getConfig, ) where @@ -17,6 +21,15 @@ import System.Console.GetOpt import Config +data CommonOptions = CommonOptions + { optJobs :: Int + } + +defaultCommonOptions :: CommonOptions +defaultCommonOptions = CommonOptions + { optJobs = 2 + } + class CommandArgumentsType (CommandArguments c) => Command c where commandName :: proxy c -> String commandDescription :: proxy c -> String @@ -54,8 +67,11 @@ instance CommandArgumentsType (Maybe Text) where argsFromStrings _ = throwError "expected at most one argument" -newtype CommandExec a = CommandExec (ReaderT Config IO a) +newtype CommandExec a = CommandExec (ReaderT ( CommonOptions, Config ) IO a) deriving (Functor, Applicative, Monad, MonadIO) +getCommonOptions :: CommandExec CommonOptions +getCommonOptions = CommandExec (asks fst) + getConfig :: CommandExec Config -getConfig = CommandExec ask +getConfig = CommandExec (asks snd) |