@@ -2,6 +2,7 @@
22import Stackage.Types
33import Stackage.Build (build, defaultBuildSettings)
44import Stackage.Init (stackageInit)
5+import Stackage.Util (allowPermissive)
56import System.Environment (getArgs, getProgName)
67import Data.Set (fromList)
78import System.IO (hFlush, stdout)
@@ -10,16 +11,26 @@ data BuildArgs = BuildArgs
1011 { noClean :: Bool
1112 , excluded :: [String]
1213 , noPlatform :: Bool
14+ , onlyPermissive :: Bool
15+ , allowed :: [String]
1316 }
1417
1518parseBuildArgs :: [String] -> IO BuildArgs
1619parseBuildArgs =
17− loop $ BuildArgs False [] False
20+ loop BuildArgs
21+ { noClean = False
22+ , excluded = []
23+ , noPlatform = False
24+ , onlyPermissive = False
25+ , allowed = []
26+ }
1827 where
1928 loop x [] = return x
2029 loop x ("--no-clean":rest) = loop x { noClean = True } rest
2130 loop x ("--exclude":y:rest) = loop x { excluded = y : excluded x } rest
2231 loop x ("--no-platform":rest) = loop x { noPlatform = True } rest
32+ loop x ("--only-permissive":rest) = loop x { onlyPermissive = True } rest
33+ loop x ("--allow":y:rest) = loop x { allowed = y : allowed x } rest
2334 loop _ (y:_) = error $ "Did not understand argument: " ++ y
2435
2536main :: IO ()
@@ -32,6 +43,10 @@ main = do
3243 { cleanBeforeBuild = not noClean
3344 , excludedPackages = fromList $ map PackageName excluded
3445 , requireHaskellPlatform = not noPlatform
46+ , allowedPackage =
47+ if onlyPermissive
48+ then allowPermissive allowed
49+ else const $ Right ()
3550 }
3651 ["init"] -> do
3752 putStrLn "Note: init isn't really ready for prime time use."
@@ -49,5 +64,5 @@ main = do
4964 putStrLn "Available commands:"
5065 putStrLn " update Download updated Stackage databases. Automatically calls init."
5166 putStrLn " init Initialize your cabal file to use Stackage"
52− putStrLn " build [--no-clean] [--no-platform] [--exclude package...]"
67+ putStrLn " build [--no-clean] [--no-platform] [--exclude package...] [--only-permissive] [--allow package]"
5368 putStrLn " Build the package databases (maintainers only)"