aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2017-06-27 06:12:35 +0300
committerIgor Pashev <pashev.igor@gmail.com>2017-06-27 06:16:09 +0300
commit88c9cc89af214745df687ae4a5ba2373825165ee (patch)
tree2193c69b8d8dc3856b3b38cca8eb97641bc31fea
parent24fcc0c1af2e0c420127686bd5edec40ebb3e039 (diff)
downloadmolodivo-88c9cc89af214745df687ae4a5ba2373825165ee.tar.gz
Support per-ministry limits in the command-line utility
-rw-r--r--cmd/Main.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/cmd/Main.hs b/cmd/Main.hs
index 35a42a6..7af6a83 100644
--- a/cmd/Main.hs
+++ b/cmd/Main.hs
@@ -5,6 +5,7 @@ module Main
) where
import Control.Monad (when)
+import Data.Maybe (fromMaybe)
import Data.Version (showVersion)
import System.Environment (getArgs)
import System.Exit (die)
@@ -16,11 +17,12 @@ import System.Console.Docopt.NoTH
(isPresent, longOption, parseArgsOrExit, parseUsageOrExit, usage)
import Text.InterpolatedString.Perl6 (qc)
-import Malodivo.Budget (manyToMany)
+import Malodivo.Budget (manyToManyLimited)
+import Malodivo.Types.District (di2df)
+import Malodivo.Types.Ministry (mi2ml)
import qualified Main.Input as I
import qualified Main.Output as O
-import Malodivo.Types.District (di2df)
import Paths_malodivo (version) -- from cabal
usageHelp :: String
@@ -49,8 +51,10 @@ process = do
Right si ->
let allBills = I.bills si
suppliedFunds = di2df $ I.districts si
+ ministryLimits = mi2ml $ fromMaybe [] (I.ministries si)
in do when (HM.null suppliedFunds) $ die "We needs at least one district"
- L.putStr . encode . O.encode $ manyToMany suppliedFunds allBills
+ L.putStr . encode . O.encode $
+ manyToManyLimited suppliedFunds ministryLimits allBills
main :: IO ()
main = do