From 00d1489556d28d5e727f207c209163fcd9429084 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sat, 5 Dec 2020 18:37:53 -0500 Subject: Bild multiple targets, and use docopt --- Biz/Bild.hs | 24 +++++++++++++++++++----- Biz/Bild/Deps/Haskell.nix | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Biz/Bild.hs b/Biz/Bild.hs index 81ab44f..4f3a186 100644 --- a/Biz/Bild.hs +++ b/Biz/Bild.hs @@ -1,5 +1,6 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE NoImplicitPrelude #-} @@ -118,9 +119,9 @@ 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 qualified System.Console.Docopt as Docopt import qualified System.Directory as Dir import qualified System.Environment as Env -import qualified System.Exit as Exit import System.FilePath (()) import qualified System.FilePath as File import qualified System.Process as Process @@ -128,10 +129,23 @@ import qualified Text.Regex.Applicative as Regex import qualified Prelude main :: IO () -main = - Env.getArgs /> head >>= \case - Nothing -> Exit.die "usage: bild " - Just target -> analyze target >>= build +main = Env.getArgs >>= Docopt.parseArgsOrExit help >>= run + where + run args = + Docopt.getAllArgs args (Docopt.argument "target") + |> mapM_ (\target -> analyze target >>= build) + +help :: Docopt.Docopt +help = + [Docopt.docopt| +bild + +Usage: + bild ... + +Options: + -v, --verbose Show output from underlying compiler +|] data Ext = Hs | Scm | Nix deriving (Show) diff --git a/Biz/Bild/Deps/Haskell.nix b/Biz/Bild/Deps/Haskell.nix index ce75805..5263163 100644 --- a/Biz/Bild/Deps/Haskell.nix +++ b/Biz/Bild/Deps/Haskell.nix @@ -11,6 +11,7 @@ "config-ini" "containers" "directory" + "docopt" "ekg" "envy" "fast-logger" -- cgit v1.2.3