diff options
author | stuebinm | 2021-09-30 14:01:25 +0200 |
---|---|---|
committer | stuebinm | 2021-09-30 14:01:25 +0200 |
commit | e68d652323e454abf7e6c01ecedd919859cf9274 (patch) | |
tree | c64dc6b857b69d599b3b9e74923eca46301eb6ec /lib/Types.hs | |
parent | ca8552c4eb69b2b8267fe0046320bccf9f547b52 (diff) |
nicer json output which leaks less haskell names
Diffstat (limited to '')
-rw-r--r-- | lib/Types.hs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/Types.hs b/lib/Types.hs index fd2bd20..c39297f 100644 --- a/lib/Types.hs +++ b/lib/Types.hs @@ -26,7 +26,7 @@ import WithCli.Pure (Argument (argumentType, parseArgumen -- | Levels of errors and warnings, collectively called -- "Hints" until I can think of some better name data Level = Info | Suggestion | Warning | Forbidden | Error | Fatal - deriving (Show, Generic, ToJSON, Ord, Eq, A.FromJSON) + deriving (Show, Generic, Ord, Eq, ToJSON) instance Argument Level where argumentType Proxy = "Lint Level" @@ -54,7 +54,7 @@ data Dep = Local RelPath | Link Text | MapLink Text | LocalMap RelPath data Hint = Hint { hintLevel :: Level , hintMsg :: Text - } deriving (Generic, ToJSON) + } deriving (Generic) -- | shorter constructor (called hint because (a) older name and -- (b) lint also exists and is monadic) @@ -75,13 +75,14 @@ instance PrettyPrint Lint where " Info: map offers entrypoint " <> prettyprint dep instance ToJSON Lint where - toJSON (Lint l) = toJSON l + toJSON (Lint (Hint l m)) = A.object + [ "msg" .= m, "level" .= l ] toJSON (Depends dep) = A.object - [ "hintMsg" .= prettyprint dep - , "hintLevel" .= A.String "Dependency Info" ] + [ "msg" .= prettyprint dep + , "level" .= A.String "Dependency Info" ] toJSON (Offers l) = A.object - [ "hintMsg" .= prettyprint l - , "hintLevel" .= A.String "Entrypoint Info" ] + [ "msg" .= prettyprint l + , "level" .= A.String "Entrypoint Info" ] instance ToJSON Dep where toJSON = \case |