@@ -8,8 +8,9 @@ import qualified Paths_spago as Pcli
88import qualified System.Environment as Env
99import qualified Turtle as T
1010
11- import Spago.Build (ExtraArg (.. ), ModuleName (.. ), SourcePath (.. ),
12- TargetPath (.. ), WithMain (.. ), Watch (.. ), NoBuild (.. ))
11+ import Spago.Build (BuildOptions (.. ), ExtraArg (.. ), ModuleName (.. ),
12+ NoBuild (.. ), SourcePath (.. ), TargetPath (.. ), Watch (.. ),
13+ WithMain (.. ))
1314import qualified Spago.Build
1415import Spago.Packages (PackageName (.. ), PackagesFilter (.. ))
1516import qualified Spago.Packages
@@ -36,9 +37,8 @@ data Command
3637 -- | Generate documentation for the project and its dependencies
3738 | Docs [SourcePath ]
3839
39- -- | Build the project paths src/ and test/
40- -- plus the specified source paths
41- | Build (Maybe Int ) Watch [SourcePath ] [ExtraArg ]
40+ -- | Build the project paths src/ and test/ plus the specified source paths
41+ | Build BuildOptions
4242
4343 -- | List available packages
4444 | ListPackages (Maybe PackagesFilter )
@@ -50,18 +50,18 @@ data Command
5050 | VerifySet (Maybe Int )
5151
5252 -- | Test the project with some module, default Test.Main
53- | Test (Maybe ModuleName ) ( Maybe Int ) Watch [ SourcePath ] [ ExtraArg ]
53+ | Test (Maybe ModuleName ) BuildOptions
5454
5555 -- | Run the project with some module, default Main
56- | Run (Maybe ModuleName ) ( Maybe Int ) Watch [ SourcePath ] [ ExtraArg ]
56+ | Run (Maybe ModuleName ) BuildOptions
5757
5858 -- | Bundle the project, with optional main and target path arguments
5959 -- Builds the project before bundling
60- | Bundle (Maybe ModuleName ) (Maybe TargetPath ) NoBuild [ SourcePath ] [ ExtraArg ]
60+ | Bundle (Maybe ModuleName ) (Maybe TargetPath ) NoBuild BuildOptions
6161
6262 -- | Bundle a module into a CommonJS module
6363 -- Builds the project before bundling
64- | MakeModule (Maybe ModuleName ) (Maybe TargetPath ) NoBuild [ SourcePath ] [ ExtraArg ]
64+ | MakeModule (Maybe ModuleName ) (Maybe TargetPath ) NoBuild BuildOptions
6565
6666 -- | Upgrade the package-set to the latest release
6767 | PackageSetUpgrade
@@ -106,12 +106,12 @@ parser = projectCommands
106106 watch = do
107107 res <- watchBool
108108 pure $ case res of
109- True -> Watch
109+ True -> Watch
110110 False -> BuildOnce
111111 noBuild = do
112112 res <- noBuildBool
113113 pure $ case res of
114- True -> NoBuild
114+ True -> NoBuild
115115 False -> DoBuild
116116 mainModule = T. optional (T. opt (Just . ModuleName ) " main" ' m' " The main module to bundle" )
117117 toTarget = T. optional (T. opt (Just . TargetPath ) " to" ' t' " The target file path" )
@@ -120,6 +120,7 @@ parser = projectCommands
120120 packageName = T. arg (Just . PackageName ) " package" " Specify a package name. You can list them with `list-packages`"
121121 packageNames = T. many $ T. arg (Just . PackageName ) " package" " Package name to add as dependency"
122122 passthroughArgs = T. many $ T. arg (Just . ExtraArg ) " ..any `purs compile` option" " Options passed through to `purs compile`; use -- to separate"
123+ buildOptions = BuildOptions <$> limitJobs <*> watch <*> sourcePaths <*> passthroughArgs
123124 packagesFilter =
124125 let wrap = \ case
125126 " direct" -> Just DirectDeps
@@ -147,7 +148,7 @@ parser = projectCommands
147148 build =
148149 ( " build"
149150 , " Install the dependencies and compile the current package"
150- , Build <$> limitJobs <*> watch <*> sourcePaths <*> passthroughArgs
151+ , Build <$> buildOptions
151152 )
152153
153154 repl =
@@ -159,25 +160,25 @@ parser = projectCommands
159160 test =
160161 ( " test"
161162 , " Test the project with some module, default Test.Main"
162- , Test <$> mainModule <*> limitJobs <*> watch <*> sourcePaths <*> passthroughArgs
163+ , Test <$> mainModule <*> buildOptions
163164 )
164-
165+
165166 run =
166167 ( " run"
167168 , " Runs the project with some module, default Main"
168- , Run <$> mainModule <*> limitJobs <*> watch <*> sourcePaths <*> passthroughArgs
169+ , Run <$> mainModule <*> buildOptions
169170 )
170171
171172 bundle =
172173 ( " bundle"
173174 , " Bundle the project, with optional main and target path arguments"
174- , Bundle <$> mainModule <*> toTarget <*> noBuild <*> sourcePaths <*> passthroughArgs
175+ , Bundle <$> mainModule <*> toTarget <*> noBuild <*> buildOptions
175176 )
176177
177178 makeModule =
178179 ( " make-module"
179180 , " Bundle a module into a CommonJS module"
180- , MakeModule <$> mainModule <*> toTarget <*> noBuild <*> sourcePaths <*> passthroughArgs
181+ , MakeModule <$> mainModule <*> toTarget <*> noBuild <*> buildOptions
181182 )
182183
183184 docs =
@@ -298,16 +299,14 @@ main = do
298299 VerifySet limitJobs -> Spago.Packages. verify limitJobs Nothing
299300 PackageSetUpgrade -> Spago.Packages. upgradePackageSet
300301 Freeze -> Spago.Packages. freeze
301- Build limitJobs watch paths pursArgs -> Spago.Build. build limitJobs watch paths pursArgs
302- Test modName limitJobs watch paths pursArgs
303- -> Spago.Build. test modName limitJobs watch paths pursArgs
304- Run modName limitJobs watch paths pursArgs
305- -> Spago.Build. run modName limitJobs watch paths pursArgs
302+ Build buildOptions -> Spago.Build. build buildOptions Nothing
303+ Test modName buildOptions -> Spago.Build. test modName buildOptions
304+ Run modName buildOptions -> Spago.Build. run modName buildOptions
306305 Repl paths pursArgs -> Spago.Build. repl paths pursArgs
307- Bundle modName tPath build paths pursArgs
308- -> Spago.Build. bundle WithMain modName tPath build paths pursArgs
309- MakeModule modName tPath build paths pursArgs
310- -> Spago.Build. makeModule modName tPath build paths pursArgs
306+ Bundle modName tPath shouldBuild buildOptions
307+ -> Spago.Build. bundle WithMain modName tPath shouldBuild buildOptions
308+ MakeModule modName tPath shouldBuild buildOptions
309+ -> Spago.Build. makeModule modName tPath shouldBuild buildOptions
311310 Docs sourcePaths -> Spago.Build. docs sourcePaths
312311 Version -> printVersion
313312 PscPackageLocalSetup force -> PscPackage. localSetup force
0 commit comments