summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2021-02-19 12:26:10 +0100
committerTom Smeding <tom@tomsmeding.com>2021-02-19 12:26:10 +0100
commit08f53feceb1edb10f8b3a816021fb580b27e5b4c (patch)
tree0bbdc7dec598d05c36af270097533000946710b7
parent70f8330a21c335f36980f4b491d5b4e65a035c1c (diff)
Write to stderr, not stdout
-rw-r--r--Coolbal/Configure.hs2
-rw-r--r--Coolbal/FindRoot.hs2
-rw-r--r--Coolbal/Target.hs9
-rw-r--r--Main.hs3
4 files changed, 8 insertions, 8 deletions
diff --git a/Coolbal/Configure.hs b/Coolbal/Configure.hs
index 92865e7..d64b4b3 100644
--- a/Coolbal/Configure.hs
+++ b/Coolbal/Configure.hs
@@ -37,5 +37,5 @@ configure fname = do
mapM_ (\d -> hPutStrLn stderr ("- " ++ show d)) deps
exitFailure
Right (pd, _flags) -> do
- -- putStrLn ("Configured with flags: " ++ show flags)
+ -- hPutStrLn stderr ("Configured with flags: " ++ show flags)
return pd
diff --git a/Coolbal/FindRoot.hs b/Coolbal/FindRoot.hs
index ea6e297..fb65491 100644
--- a/Coolbal/FindRoot.hs
+++ b/Coolbal/FindRoot.hs
@@ -23,7 +23,7 @@ findCabalSpec = do
mfound <- findThingInDirs "cabal file" (`endsWith` ".cabal") doesFileExist FoundCabalSpec (ancestors cwd)
case mfound of
Just found -> do
- putStrLn ("Found .cabal file: " ++ foundcsCabal found)
+ hPutStrLn stderr ("Found .cabal file: " ++ foundcsCabal found)
return found
Nothing -> do
hPutStrLn stderr (".cabal file not found in ancestors of PWD: " ++ cwd)
diff --git a/Coolbal/Target.hs b/Coolbal/Target.hs
index 761f19d..64a0a16 100644
--- a/Coolbal/Target.hs
+++ b/Coolbal/Target.hs
@@ -111,17 +111,16 @@ instance IsTarget ExeTarget where
,map (intercalate ".") (exeTargetModules tg)
,["-o", binName]
,exeTargetFlags tg])
- >>= checkExitCode "ghc"
+ >>= checkExitCode
targetExecute tg = Just $ \projdir args -> do
let filename = escapeFileName (exeTargetName tg)
rawSystem (projdir </> "dist-coolbal/bin" </> filename) args
>>= exitWith
-checkExitCode :: String -> ExitCode -> IO ()
-checkExitCode _ ExitSuccess = return ()
-checkExitCode procname (ExitFailure c) =
- die (procname ++ " exited with code " ++ show c)
+checkExitCode :: ExitCode -> IO ()
+checkExitCode ExitSuccess = return ()
+checkExitCode c@(ExitFailure _) = exitWith c
escapeFileName :: String -> FilePath
escapeFileName =
diff --git a/Main.hs b/Main.hs
index c1f5f9b..b696241 100644
--- a/Main.hs
+++ b/Main.hs
@@ -14,6 +14,7 @@ import Options.Applicative (execParser)
import System.Directory (createDirectoryIfMissing, removeDirectoryRecursive)
import System.Exit (die)
import System.FilePath ((</>))
+import System.IO (hPutStrLn, stderr)
import Coolbal.CabalPlan
import Coolbal.Configure (configure)
@@ -69,7 +70,7 @@ doConfigure = do
-- print pd
let targets = compatibleTargets pd plan
names = map (useAnyTarget (\t -> targetName t ++ " (" ++ targetNameQualified t ++ ")")) targets
- putStrLn ("Supported targets: " ++ intercalate ", " names)
+ hPutStrLn stderr ("Supported targets: " ++ intercalate ", " names)
createDirectoryIfMissing True (foundcsRootDir foundSpec </> "dist-coolbal")
B.encodeFile (foundcsRootDir foundSpec </> "dist-coolbal/targets.bin") targets