Skip to content

Commit a7a5401

Browse files
committed
Pretty print the JSON dumps.
1 parent eb1355b commit a7a5401

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

package.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ dependencies:
5252
- base >= 4.16.3.0 && < 5
5353
- Cabal >= 3.6.3.0
5454
- aeson >= 2.0.3.0
55+
- aeson-pretty
5556
- annotated-wl-pprint
5657
- ansi-terminal
5758
- array

src/Stack/ConfigCmd.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import Stack.Prelude
4848
import Data.Coerce (coerce)
4949
import Pantry.Internal.AesonExtended
5050
(ToJSON(..), FromJSON, (.=), WithJSONWarnings (WithJSONWarnings), object)
51-
import qualified Data.Aeson as Aeson
51+
import Data.Aeson.Encode.Pretty (encodePretty)
5252
import qualified Data.Aeson.Key as Key
5353
import Data.Aeson.KeyMap (KeyMap)
5454
import qualified Data.Aeson.KeyMap as KeyMap
@@ -128,18 +128,18 @@ configCmdSetScope (ConfigCmdSetSystemGhc scope _) = scope
128128
configCmdSetScope (ConfigCmdSetInstallGhc scope _) = scope
129129

130130
encodeDumpProject :: RawYaml -> ConfigDumpFormat -> Project -> ByteString
131-
encodeDumpProject _ ConfigDumpJson = toStrictBytes . Aeson.encode
131+
encodeDumpProject _ ConfigDumpJson = toStrictBytes . encodePretty
132132
encodeDumpProject rawConfig ConfigDumpYaml = \p -> let e = Yaml.encode p in
133133
Yaml.decodeEither' e & either (const e) (\(d :: KeyMap Yaml.Value) ->
134134
either (const e) encodeUtf8 (cfgRedress rawConfig d ""))
135135

136136
encodeDumpStackBy :: ToJSON a => (Config -> a) -> ConfigCmdDumpStack -> (Config -> ByteString)
137137
encodeDumpStackBy f (ConfigCmdDumpStack _ ConfigDumpYaml) = Yaml.encode . f
138-
encodeDumpStackBy f (ConfigCmdDumpStack _ ConfigDumpJson) = toStrictBytes . Aeson.encode . f
138+
encodeDumpStackBy f (ConfigCmdDumpStack _ ConfigDumpJson) = toStrictBytes . encodePretty . f
139139

140140
encodeDumpStack :: ConfigDumpFormat -> (DumpStack -> ByteString)
141141
encodeDumpStack ConfigDumpYaml = Yaml.encode
142-
encodeDumpStack ConfigDumpJson = toStrictBytes . Aeson.encode
142+
encodeDumpStack ConfigDumpJson = toStrictBytes . encodePretty
143143

144144
cfgReadProject :: (HasConfig env, HasLogFunc env) => CommandScope -> RIO env (Maybe Project)
145145
cfgReadProject scope = do

stack.cabal

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ library
230230
build-depends:
231231
Cabal >=3.6.3.0
232232
, aeson >=2.0.3.0
233+
, aeson-pretty
233234
, annotated-wl-pprint
234235
, ansi-terminal
235236
, array
@@ -354,6 +355,7 @@ executable stack
354355
build-depends:
355356
Cabal >=3.6.3.0
356357
, aeson >=2.0.3.0
358+
, aeson-pretty
357359
, annotated-wl-pprint
358360
, ansi-terminal
359361
, array
@@ -477,6 +479,7 @@ executable stack-integration-test
477479
build-depends:
478480
Cabal >=3.6.3.0
479481
, aeson >=2.0.3.0
482+
, aeson-pretty
480483
, annotated-wl-pprint
481484
, ansi-terminal
482485
, array
@@ -608,6 +611,7 @@ test-suite stack-test
608611
Cabal >=3.6.3.0
609612
, QuickCheck
610613
, aeson >=2.0.3.0
614+
, aeson-pretty
611615
, annotated-wl-pprint
612616
, ansi-terminal
613617
, array

0 commit comments

Comments
 (0)