-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.hs
34 lines (26 loc) · 952 Bytes
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module Main where
import Hrange
import Data.Foldable (toList)
import Data.List (sort)
import qualified Data.Text as T
import System.Environment (getArgs)
import System.Exit (die)
import Text.Show.Pretty
main :: IO ()
main = do
args <- getArgs
case length args of
2 -> return ()
_ -> die "Usage: ergh DIR QUERY"
let stateDir = args !! 0
let query = T.pack $ args !! 1
(state, _) <- loadStateFromDirectory stateDir
let state' = analyze state
putStrLn $ ppShow state'
putStrLn ""
case expandDebug state' query of
Left err -> die $ "Invalid query: " ++ show err
Right (results, debug) -> do
putStrLn $ ppShow debug
putStrLn ""
putStr . T.unpack . T.unlines . sort . toList $ results