diff options
author | Ben Sima <ben@bsima.me> | 2021-01-16 05:19:10 -0500 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2021-01-16 05:22:11 -0500 |
commit | 79fc1bd6a51a97b905b1f15c6b74c0a8062aaa89 (patch) | |
tree | 034488adbd9dabe199747b3a8fbbf3b610450d3d /Biz/Bild.hs | |
parent | ad89499b4e960044a4c894757dd2c500fe044759 (diff) |
Add colors to tooling outputs
This makes scanning logs *much* easier. I figure keep it as simple as possible,
just red, yellow, and green.
I also added two spaces between labels in the log messages. It would be nice to
have a more structured logging system, but for now this works.
Diffstat (limited to 'Biz/Bild.hs')
-rw-r--r-- | Biz/Bild.hs | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/Biz/Bild.hs b/Biz/Bild.hs index 721da46..9c341b9 100644 --- a/Biz/Bild.hs +++ b/Biz/Bild.hs @@ -9,6 +9,9 @@ -- : out bild -- : dep docopt -- : dep regex-applicative +-- : dep rainbow +-- : dep tasty +-- : dep tasty-hunit -- -- == Design constraints -- @@ -125,6 +128,7 @@ import qualified Data.Char as Char import qualified Data.List as List import qualified Data.String as String import qualified Data.Text as Text +import Rainbow (chunk, fore, green, putChunkLn, red) import qualified System.Directory as Dir import qualified System.Environment as Env import System.FilePath ((</>)) @@ -289,10 +293,10 @@ build andTest target@Target {..} = do root <- Env.getEnv "BIZ_ROOT" case compiler of GhcExe -> do - putStrLn <| "bild: dev: ghc-exe: " <> Namespace.toPath namespace + putStrLn <| "bild: dev: ghc-exe: " <> Namespace.toPath namespace let outDir = root </> "_/bild/dev/bin" Dir.createDirectoryIfMissing True outDir - putText <| "bild: dev: bilder: " <> Text.pack builder + putText <| "bild: dev: bilder: " <> Text.pack builder Process.callProcess "ghc" [ "-Werror", @@ -309,11 +313,12 @@ build andTest target@Target {..} = do outDir </> out ] when andTest <| do - putStrLn <| "bild: dev: test: " <> Namespace.toPath namespace + putStrLn <| "bild: dev: test: " <> Namespace.toPath namespace Process.callProcess (outDir </> out) ["test"] + putChunkLn <| fore green <| "bilt: " <> nschunk namespace GhcLib -> do - putStrLn <| "bild: dev: ghc-lib: " <> Namespace.toPath namespace - putText <| "bild: dev: bilder: " <> Text.pack builder + putStrLn <| "bild: dev: ghc-lib: " <> Namespace.toPath namespace + putText <| "bild: dev: bilder: " <> Text.pack builder Process.callProcess "ghc" [ "-Werror", @@ -325,11 +330,12 @@ build andTest target@Target {..} = do "--make", path ] + putChunkLn <| fore green <| "bilt: " <> nschunk namespace GhcjsExe -> do - putStrLn <| "bild: dev: ghcjs-exe: " <> Namespace.toPath namespace + putStrLn <| "bild: dev: ghcjs-exe: " <> Namespace.toPath namespace let outDir = root </> "_/bild/dev/static" Dir.createDirectoryIfMissing True outDir - putText <| "bild: dev: local: " <> Text.pack builder + putText <| "bild: dev: local: " <> Text.pack builder Process.callProcess "ghcjs" [ "-Werror", @@ -345,9 +351,10 @@ build andTest target@Target {..} = do "-o", outDir </> out ] + putChunkLn <| fore green <| "bilt: " <> nschunk namespace GhcjsLib -> do - putStrLn <| "bild: dev: ghcjs-lib: " <> Namespace.toPath namespace - putText <| "bild: dev: local: " <> Text.pack builder + putStrLn <| "bild: dev: ghcjs-lib: " <> Namespace.toPath namespace + putText <| "bild: dev: local: " <> Text.pack builder Process.callProcess "ghcjs" [ "-Werror", @@ -359,18 +366,19 @@ build andTest target@Target {..} = do "--make", path ] + putChunkLn <| fore green <| "bilt: " <> nschunk namespace Guile -> do - putStrLn <| "bild: dev: guile: " <> Namespace.toPath namespace - putText <| "bild: dev: local: " <> Text.pack builder - putText "bild: guile TODO" + putStrLn <| "bild: dev: guile: " <> Namespace.toPath namespace + putText <| "bild: dev: local: " <> Text.pack builder + putText "bild: guile: TODO" putText <| show target NixBuild -> do - putStrLn <| "bild: nix: " <> Namespace.toPath namespace + putStrLn <| "bild: nix: " <> Namespace.toPath namespace let outDir = root </> "_/bild/nix" Dir.createDirectoryIfMissing True outDir if null builder - then putText <| "bild: nix: local" - else putText <| "bild: nix: remote: " <> Text.pack builder + then putText <| "bild: nix: local" + else putText <| "bild: nix: remote: " <> Text.pack builder Process.callProcess "nix-build" [ path, @@ -391,11 +399,14 @@ build andTest target@Target {..} = do "--builders", builder ] + putChunkLn <| fore green <| "bilt: " <> nschunk namespace Copy -> do - putStrLn <| "bild: copy: " <> Namespace.toPath namespace - putText "bild: copy TODO" + putStrLn <| "bild: copy: " <> Namespace.toPath namespace + putText "bild: copy: TODO" putText <| show target +nschunk = chunk <. Text.pack <. Namespace.toPath + metaDep :: Regex.RE Char Dep metaDep = Regex.string "-- : dep " *> Regex.many (Regex.psym Char.isAlpha) |