Move all output to a sum type

All errors, warnings, and messages are now listed in a sum type
in 'CAStore.Type.Text'. The added structure should help with
writing better error messages. Also, if and when we get to
localising ca-store, implementation will be trivial.
This commit is contained in:
hylodon 2025-09-18 16:12:46 +01:00
parent 1971897eb8
commit 68bba7c653
10 changed files with 74 additions and 21 deletions

View file

@ -3,8 +3,8 @@ module Main(main) where
import CAStore.Command (runCommand)
import CAStore.Config (finalConfig)
import CAStore.Program (Program, runProgram, getCommand)
import CAStore.Program.IO.Text (err)
import CAStore.Program.Storage (initialise)
import Control.Monad.IO.Class (liftIO)
main :: IO ()
main = finalConfig >>= flip runProgram defaultProgram
@ -12,6 +12,4 @@ main = finalConfig >>= flip runProgram defaultProgram
defaultProgram :: Program ()
defaultProgram = do
initialise
getCommand >>= \case
Nothing -> liftIO $ putStrLn "ERROR: Invalid command"
Just cmd -> runCommand cmd
getCommand >>= either err runCommand