@@ -1,14 +1,34 @@
1−import Stackage.Types (BuildSettings(..))
1+{-# LANGUAGE RecordWildCards #-}
2+import Stackage.Types
23import Stackage.Build (build, defaultBuildSettings)
34import Stackage.Init (stackageInit)
45import System.Environment (getArgs, getProgName)
6+import Data.Set (fromList)
7+
8+data BuildArgs = BuildArgs
9+ { noClean :: Bool
10+ , excluded :: [String]
11+ }
12+
13+parseBuildArgs :: [String] -> IO BuildArgs
14+parseBuildArgs =
15+ loop $ BuildArgs False []
16+ where
17+ loop x [] = return x
18+ loop x ("--no-clean":rest) = loop x { noClean = True } rest
19+ loop x ("--exclude":y:rest) = loop x { excluded = y : excluded x } rest
20+ loop _ (y:_) = error $ "Did not understand argument: " ++ y
521
622main :: IO ()
723main = do
824 args <- getArgs
925 case args of
10− ["build"] -> build defaultBuildSettings
11− ["build", "--no-clean"] -> build (defaultBuildSettings { cleanBeforeBuild = False })
26+ "build":rest -> do
27+ BuildArgs {..} <- parseBuildArgs rest
28+ build defaultBuildSettings
29+ { cleanBeforeBuild = not noClean
30+ , excludedPackages = fromList $ map PackageName excluded
31+ }
1232 ["init"] -> stackageInit
1333 ["update"] -> stackageInit >> error "FIXME update"
1434 _ -> do
@@ -17,4 +37,5 @@ main = do
1737 putStrLn "Available commands:"
1838 putStrLn " update Download updated Stackage databases. Automatically calls init."
1939 putStrLn " init Initialize your cabal file to use Stackage"
20− putStrLn " build [--no-clean] Build the package databases (maintainers only)"
40+ putStrLn " build [--no-clean] [--exclude package...]"
41+ putStrLn " Build the package databases (maintainers only)"