Skip to content

Commit e8e9b50

Browse files
committed
Make CLI more elaborate
1 parent b67afb4 commit e8e9b50

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

cli/Main.hs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,16 @@ mainSingle args = do
122122

123123
mainDiff :: [String] -> IO ()
124124
mainDiff args = do
125-
args <- getArgs
126-
when (length args < 3) $ fail "Need a target and 2 revisions to compare."
127-
let target = args !! 0
128-
rev1 = args !! 1
129-
rev2 = args !! 2
130-
(Just file1) <- checkoutAndGenerateHoogleFile target rev1
131-
(Just file2) <- checkoutAndGenerateHoogleFile target rev2
132-
putStrLn $ unwords ["File for", rev1, ":", file1]
133-
putStrLn $ unwords ["File for", rev2, ":", file2]
125+
when (length args < 4)
126+
$ fail "target1 revision-for-target1 target2 revision-for-target-2"
127+
let target1 = args !! 0
128+
revTarget1 = args !! 1
129+
target2 = args !! 2
130+
revTarget2 = args !! 3
131+
(Just file1) <- checkoutAndGenerateHoogleFile target1 revTarget1
132+
(Just file2) <- checkoutAndGenerateHoogleFile target2 revTarget2
133+
putStrLn $ unwords ["File for", target1, revTarget1, ":", file1]
134+
putStrLn $ unwords ["File for", target2, revTarget2, ":", file2]
134135
api1 <-
135136
fileToLines file1
136137
& Stream.fold (haddockParseFold Removed Removed Removed)
@@ -166,13 +167,11 @@ mainDiff args = do
166167
isDeprecatedInLeft (Tagged (Attach (DBoth anns _) _) _) =
167168
isDeprecated anns
168169
isDeprecatedInLeft _ = False
169-
170170
let diff =
171171
let filt k v =
172172
not (isInternal k)
173173
&& not (isDeprecatedInBoth v || isDeprecatedInLeft v)
174-
in Map.filterWithKey filt (diffAPI api1 api2)
175-
174+
in Map.filterWithKey filt (diffAPI api1 api2)
176175
putStrLn $ prettyAPI elems diff
177176

178177
main :: IO ()

0 commit comments

Comments
 (0)