Skip to content

Commit 2744524

Browse files
committed
Reorganize modules
1 parent e808ec7 commit 2744524

File tree

4 files changed

+30
-25
lines changed

4 files changed

+30
-25
lines changed

hi.cabal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ description:
5252
library
5353
exposed-modules:
5454
Hi
55+
Hi.Cli
5556
Hi.Directory
5657
Hi.FilePath
5758
Hi.Git
@@ -81,7 +82,7 @@ library
8182

8283
executable hi
8384
main-is:
84-
Cli.hs
85+
Main.hs
8586
ghc-options:
8687
-Wall
8788
hs-source-dirs:

src/Cli.hs renamed to src/Hi/Cli.hs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
module Cli
2-
( main
3-
, runWithArgs
1+
module Hi.Cli
2+
( run
43
) where
54

65
import qualified Hi
@@ -11,15 +10,11 @@ import qualified Hi.Version as Version
1110

1211
import Data.Monoid (mempty)
1312
import Options.Applicative
14-
import System.Environment (getArgs)
1513
import qualified Text.PrettyPrint.ANSI.Leijen as PP
1614

17-
main :: IO ()
18-
main = getArgs >>= runWithArgs
19-
20-
runWithArgs :: [String] -> IO ()
21-
runWithArgs [] = showHelpText (prefs idm) opts
22-
runWithArgs args = (handleParseResult $ execParserPure (prefs idm) opts args) >>= buildOption >>= Hi.run
15+
run :: [String] -> IO ()
16+
run [] = showHelpText (prefs idm) opts
17+
run args = (handleParseResult $ execParserPure (prefs idm) opts args) >>= buildOption >>= Hi.run
2318

2419
opts :: ParserInfo CommandLineOption
2520
opts = info (helper <*> (version <*> commandLineOption))

src/Main.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module Main
2+
( main
3+
) where
4+
5+
import Hi.Cli (run)
6+
import System.Environment (getArgs)
7+
8+
main :: IO ()
9+
main = getArgs >>= run

test/FeatureSpec.hs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module FeatureSpec ( spec ) where
44

5-
import Cli as Cli
5+
import qualified Hi.Cli as Cli
66
import Hi.Directory (inDirectory)
77
import Hi.Version (version)
88

@@ -39,10 +39,10 @@ spec = do
3939

4040
describe "with --initialize-git-repository" $ do
4141
let cmd = runWithCommandLineOptions [ "--initialize-git-repository"
42-
, "-p"
43-
, packageName
44-
, "-m"
45-
, moduleName ]
42+
, "-p"
43+
, packageName
44+
, "-m"
45+
, moduleName ]
4646
around cmd $ do
4747
it "should initialize it as git repository and make first commit" $ do
4848
inDirectory "./testapp" $ do
@@ -53,7 +53,7 @@ spec = do
5353
let handle ExitSuccess = return ()
5454
handle e = throwIO e
5555

56-
(res,_) <- capture $ Cli.runWithArgs ["-v"] `catch` handle
56+
(res,_) <- capture $ Cli.run ["-v"] `catch` handle
5757
res `shouldBe` version ++ "\n"
5858

5959
packageName, moduleName, author, email :: String
@@ -146,10 +146,10 @@ runWithCommandLineOptions opts action = do
146146
pwd <- getCurrentDirectory
147147

148148
inTestDirectory $ do
149-
Cli.runWithArgs $ opts ++ [ "-a", quote author
150-
, "-e", quote email
151-
, "-r file://" ++ pwd ++ "/template"
152-
]
149+
Cli.run $ opts ++ [ "-a", quote author
150+
, "-e", quote email
151+
, "-r file://" ++ pwd ++ "/template"
152+
]
153153
action
154154

155155
runWithLocalGitConfig :: [String] -> IO () -> IO ()
@@ -160,10 +160,10 @@ runWithLocalGitConfig opts action = do
160160
_ <- system $ "git init"
161161
_ <- system $ "git config user.name" ++ " " ++ quote author
162162
_ <- system $ "git config user.email" ++ " " ++ quote email
163-
Cli.runWithArgs $ opts ++ [ "-a", quote author
164-
, "-e", quote email
165-
, "-r file://" ++ pwd ++ "/template"
166-
]
163+
Cli.run $ opts ++ [ "-a", quote author
164+
, "-e", quote email
165+
, "-r file://" ++ pwd ++ "/template"
166+
]
167167
action
168168

169169
inTestDirectory :: IO () -> IO ()

0 commit comments

Comments
 (0)