module Obs.Main import Data.DPair import Obs.Abstract import Obs.Logging import Obs.NormalForm import Obs.Parser import Obs.Syntax import Obs.Term import Obs.Typing import System import System.File import Text.PrettyPrint.Prettyprinter.Render.Terminal %default total record Options where constructor MkOptions file : String lvl : Level usage : String -> IO a usage prog = do () <- putStrLn "usage: \{prog} " exitFailure parseLevel : String -> Maybe Level parseLevel "0" = Just Error parseLevel "1" = Just Warn parseLevel "2" = Just Debug parseLevel "3" = Just Info parseLevel "4" = Just Trace parseLevel "error" = Just Error parseLevel "warn" = Just Warn parseLevel "debug" = Just Debug parseLevel "info" = Just Info parseLevel "trace" = Just Trace parseLevel _ = Nothing parseOptions : List1 String -> IO Options parseOptions (prog ::: [file, "-v", lvl]) = do let Just lvl = parseLevel lvl | Nothing => usage prog pure $ MkOptions file lvl parseOptions (prog ::: [file, "-v"]) = pure $ MkOptions file Debug parseOptions (prog ::: [file]) = pure $ MkOptions file Error parseOptions (prog ::: _) = usage prog partial main' : (input: String) -> Logging AnsiStyle (Exists NormalForm.Context) main' input = do defs <- parse input blk <- abstractBlock defs ctx <- checkBlock blk pure (Evidence _ ctx) partial main : IO () main = do (prog :: args) <- getArgs | _ => usage "obs" opts <- parseOptions (prog ::: args) Right input <- readFile opts.file | Left err => do putStrLn "failed to open file: \{show err}"; exitFailure ctx <- logToTerminal opts.lvl $ main' input putStrLn "Everything type checks."