Skip to content

Commit 991835e

Browse files
Profpatschpaf31
authored andcommitted
add --pass-through to build and repl (#35)
* add `--pass-through` to build and repl It should be possible to pass through arguments to the called `purs` commands, like in this case `compile` and `repl`. This is needed for e.g. using `purs compile --json-errors` to integrate psc-package into editors. * switch from `--pass-through` to implicit passthrough People think this is a more usable solution. I disagree, but it’s not really important enough to argue over.
1 parent f59ea9a commit 991835e

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

app/Main.hs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,16 +307,20 @@ listSourcePaths = do
307307
paths <- getPaths
308308
traverse_ (echoT . pathToTextUnsafe) paths
309309

310-
exec :: [String] -> Bool -> IO ()
311-
exec execNames onlyDeps = do
310+
-- | helper for calling through to @purs@
311+
--
312+
-- extra args will be appended to the options
313+
exec :: [String] -> Bool -> [String] -> IO ()
314+
exec execNames onlyDeps passthroughOptions = do
312315
paths <- getPaths
313316
let cmdParts = tail execNames
314317
srcParts = [ "src" </> "**" </> "*.purs" | not onlyDeps ]
315318
exit
316319
=<< Process.waitForProcess
317320
=<< Process.runProcess
318321
(head execNames)
319-
(cmdParts <> map Path.encodeString (srcParts <> paths))
322+
(cmdParts <> passthroughOptions
323+
<> map Path.encodeString (srcParts <> paths))
320324
Nothing -- no special path to the working dir
321325
Nothing -- no env vars
322326
Nothing -- use existing stdin
@@ -455,10 +459,16 @@ main = do
455459
(Opts.info (install <$> pkg Opts.<**> Opts.helper)
456460
(Opts.progDesc "Install the named package"))
457461
, Opts.command "build"
458-
(Opts.info (exec ["purs", "compile"] <$> onlyDeps "Compile only the package's dependencies" Opts.<**> Opts.helper)
462+
(Opts.info (exec ["purs", "compile"]
463+
<$> onlyDeps "Compile only the package's dependencies"
464+
<*> passthroughArgs "purs compile"
465+
Opts.<**> Opts.helper)
459466
(Opts.progDesc "Build the current package and dependencies"))
460467
, Opts.command "repl"
461-
(Opts.info (exec ["purs", "repl"] <$> onlyDeps "Load only the package's dependencies" Opts.<**> Opts.helper)
468+
(Opts.info (exec ["purs", "repl"]
469+
<$> onlyDeps "Load only the package's dependencies"
470+
<*> passthroughArgs "purs repl"
471+
Opts.<**> Opts.helper)
462472
(Opts.progDesc "Open an interactive environment for PureScript"))
463473
, Opts.command "dependencies"
464474
(Opts.info (pure listDependencies)
@@ -494,6 +504,10 @@ main = do
494504
<> Opts.short 'd'
495505
<> Opts.help help
496506

507+
passthroughArgs cmd = many $ Opts.strArgument $
508+
Opts.help ("Options passed through to " <> cmd <> "; use -- to separate")
509+
<> Opts.metavar ("`" <> cmd <> "`" <> "-options")
510+
497511
sorted = Opts.switch $
498512
Opts.long "sort"
499513
<> Opts.short 's'

0 commit comments

Comments
 (0)