start on serializing Messages

Json objects not yet handled, and some other special cases, but this is
the bulk of the messages.

For progress meters, POSIXTime does not have a Read instance (or a
suitable Show instance), so had to switch to using a Double for progress
meters.

This commit was sponsored by Ethan Aubin on Patreon.
This commit is contained in:
Joey Hess 2020-12-03 13:01:28 -04:00
parent 63839532c9
commit 5a41e46bd4
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 62 additions and 25 deletions

View file

@ -1,6 +1,6 @@
{- git-annex Messages data types
-
- Copyright 2012-2018 Joey Hess <id@joeyh.name>
- Copyright 2012-2020 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
@ -8,11 +8,16 @@
module Types.Messages where
import qualified Utility.Aeson as Aeson
import Utility.Metered
import Control.Concurrent
import System.Console.Regions (ConsoleRegion)
data OutputType = NormalOutput | QuietOutput | JSONOutput JSONOptions
data OutputType
= NormalOutput
| QuietOutput
| JSONOutput JSONOptions
| SerializedOutput
deriving (Show)
data JSONOptions = JSONOptions
@ -53,3 +58,9 @@ newMessageState = do
, jsonBuffer = Nothing
, promptLock = promptlock
}
data SerializedOutput
= OutputMessage String
| OutputError String
| ProgressMeter (Maybe Integer) MeterState MeterState
deriving (Show, Read)