on master help sign in
Update command implementations to always take args and flags
e76d040Evan Czaplicki
ui/terminal/src/Bump.hs+2−3
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
2module Bump (run) where
1module Bump (run) where
3
2
4
3
@@ -14,8 +13,8 @@ import qualified Reporting.Progress.Terminal as Terminal
14-- RUN
13-- RUN
15
14
16
15
17−run :: IO ()
16+run :: () -> () -> IO ()
18−run =
17+run () () =
19 do reporter <- Terminal.create
18 do reporter <- Terminal.create
20 void $ Task.run reporter $
19 void $ Task.run reporter $
21 do summary <- Project.getRoot
20 do summary <- Project.getRoot
ui/terminal/src/Develop.hs+13−5
@@ -1,6 +1,9 @@
1−{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
3−module Develop (run) where
2+module Develop
3+ ( Flags(..)
4+ , run
5+ )
6+ where
4
7
5import Control.Applicative ((<|>))
8import Control.Applicative ((<|>))
6import Control.Concurrent (threadDelay)
9import Control.Concurrent (threadDelay)
@@ -16,7 +19,6 @@ import Snap.Util.FileServe
16import qualified Text.Blaze.Html5 as H
19import qualified Text.Blaze.Html5 as H
17import qualified Text.Blaze.Html.Renderer.Utf8 as Blaze
20import qualified Text.Blaze.Html.Renderer.Utf8 as Blaze
18
21
19−import qualified CommandLine.Args as Args
20import qualified Develop.Compile as Compile
22import qualified Develop.Compile as Compile
21import qualified Develop.Generate.Help as Generate
23import qualified Develop.Generate.Help as Generate
22import qualified Develop.Generate.Index as Index
24import qualified Develop.Generate.Index as Index
@@ -28,8 +30,14 @@ import qualified Develop.StaticFiles as StaticFiles
28-- RUN THE DEV SERVER
30-- RUN THE DEV SERVER
29
31
30
32
31−run :: Args.DevFlags -> IO ()
33+data Flags =
34+ Flags
35+ { _port :: Maybe Int
36+ }
37+
38+
39+run :: () -> Flags -> IO ()
32−run (Args.DevFlags maybePort) =
40+run () (Flags maybePort) =
33 -- TODO get `elm reactor` running again
41 -- TODO get `elm reactor` running again
34 if True then
42 if True then
35 putStrLn $
43 putStrLn $
ui/terminal/src/Diff.hs+2−2
@@ -13,7 +13,7 @@ import qualified Reporting.Progress.Terminal as Terminal
13-- RUN
13-- RUN
14
14
15
15
16−run :: Diff.Args -> IO ()
16+run :: Diff.Args -> () -> IO ()
17−run args =
17+run args () =
18 do reporter <- Terminal.create
18 do reporter <- Terminal.create
19 void $ Task.run reporter $ Diff.diff args
19 void $ Task.run reporter $ Diff.diff args
ui/terminal/src/Install.hs+2−3
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
2module Install (run) where
1module Install (run) where
3
2
4
3
@@ -14,8 +13,8 @@ import qualified Reporting.Progress.Terminal as Terminal
14-- RUN
13-- RUN
15
14
16
15
17−run :: Pkg.Name -> IO ()
16+run :: Pkg.Name -> () -> IO ()
18−run pkg =
17+run pkg () =
19 do reporter <- Terminal.create
18 do reporter <- Terminal.create
20 void $ Task.run reporter $
19 void $ Task.run reporter $
21 Install.install pkg
20 Install.install pkg
ui/terminal/src/Make.hs+18−9
@@ -1,23 +1,32 @@
1−{-# OPTIONS_GHC -Wall #-}
2−module Make (run) where
1+module Make
2+ ( Flags(..)
3+ , run
4+ )
5+ where
3
6
4
7
5import Control.Monad (void)
8import Control.Monad (void)
6
9
7import qualified Elm.Compiler.Objects as Obj
10import qualified Elm.Compiler.Objects as Obj
8import qualified Elm.Project as Project
11import qualified Elm.Project as Project
9−import qualified Elm.Project.Flags as Flags
12+import qualified Generate.Output as Output
10import qualified Reporting.Task as Task
13import qualified Reporting.Task as Task
11import qualified Reporting.Progress.Terminal as Terminal
14import qualified Reporting.Progress.Terminal as Terminal
12
15
13−import qualified CommandLine.Args as Args
14−
15
16
16
17
17-- RUN
18-- RUN
18
19
19
20
21+data Flags =
22+ Flags
23+ { _warn :: Bool
24+ , _debug :: Bool
25+ , _output :: Maybe Output.Output
26+ }
27+
28+
20−run :: [FilePath] -> Args.MakeFlags -> IO ()
29+run :: [FilePath] -> Flags -> IO ()
21run paths flags =
30run paths flags =
22 do reporter <- Terminal.create
31 do reporter <- Terminal.create
23 void $ Task.run reporter $
32 void $ Task.run reporter $
@@ -26,10 +35,10 @@ run paths flags =
26
35
27
36
28-- TODO figure out --warn flag
37-- TODO figure out --warn flag
29−toOptions :: Args.MakeFlags -> Flags.Options
38+toOptions :: Flags -> Output.Options
30−toOptions (Args.MakeFlags _warn debug output) =
39+toOptions (Flags warn debug output) =
31 let
40 let
32 mode = if debug then Obj.Debug else Obj.Prod
41 mode = if debug then Obj.Debug else Obj.Prod
33 target = if False then Obj.Server else Obj.Client
42 target = if False then Obj.Server else Obj.Client
34 in
43 in
35− Flags.Options mode target output
44+ Output.Options warn mode target output
ui/terminal/src/Publish.hs+2−3
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
2module Publish (run) where
1module Publish (run) where
3
2
4
3
@@ -14,8 +13,8 @@ import qualified Reporting.Progress.Terminal as Terminal
14-- RUN
13-- RUN
15
14
16
15
17−run :: IO ()
16+run :: () -> () -> IO ()
18−run =
17+run () () =
19 do reporter <- Terminal.create
18 do reporter <- Terminal.create
20 void $ Task.run reporter $
19 void $ Task.run reporter $
21 do summary <- Project.getRoot
20 do summary <- Project.getRoot
ui/terminal/src/Repl.hs+13−12
@@ -1,6 +1,9 @@
1−{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
3−module Repl where
2+module Repl
3+ ( Flags(..)
4+ , run
5+ )
6+ where
4
7
5
8
6import Prelude hiding (lines, read)
9import Prelude hiding (lines, read)
@@ -8,7 +11,6 @@ import Control.Applicative ((<|>))
8import Control.Monad.RWS (lift, liftIO)
11import Control.Monad.RWS (lift, liftIO)
9import qualified Control.Monad.RWS as RWS
12import qualified Control.Monad.RWS as RWS
10import qualified Data.ByteString.Builder as B
13import qualified Data.ByteString.Builder as B
11−import qualified Data.ByteString.Char8 as BS
12import qualified Data.ByteString.Lazy as LBS
14import qualified Data.ByteString.Lazy as LBS
13import qualified Data.List as List
15import qualified Data.List as List
14import qualified Data.Map as Map
16import qualified Data.Map as Map
@@ -31,15 +33,19 @@ import qualified Elm.Utils as Elm
31import qualified Reporting.Task as Task
33import qualified Reporting.Task as Task
32import qualified Reporting.Progress.Repl as Repl
34import qualified Reporting.Progress.Repl as Repl
33
35
34−import qualified CommandLine.Args as Args
35−
36
36
37
37
38-- RUN
38-- RUN
39
39
40
40
41−run :: Args.ReplFlags -> IO ()
41+data Flags =
42+ Flags
43+ { _interpreter :: Maybe FilePath
44+ }
45+
46+
47+run :: () -> Flags -> IO ()
42−run (Args.ReplFlags maybeAlternateInterpreter) =
48+run () (Flags maybeAlternateInterpreter) =
43 do interpreter <- getInterpreter maybeAlternateInterpreter
49 do interpreter <- getInterpreter maybeAlternateInterpreter
44 _ <- Project.getRootWithReplFallback
50 _ <- Project.getRootWithReplFallback
45 putStrLn welcomeMessage
51 putStrLn welcomeMessage
@@ -131,11 +137,6 @@ eval input =
131 report "I cannot handle port declarations."
137 report "I cannot handle port declarations."
132
138
133
139
134−toUtf8 :: String -> BS.ByteString
135−toUtf8 string =
136− LBS.toStrict (B.toLazyByteString (B.stringUtf8 string))
137−
138−
139report :: String -> Runner (Maybe a)
140report :: String -> Runner (Maybe a)
140report msg =
141report msg =
141 do liftIO (putStrLn msg)
142 do liftIO (putStrLn msg)