Skip to content

Commit 01e646f

Browse files
committed
Make use of outputFormat field in the query spo-stake-distribution command
1 parent 0c56bcd commit 01e646f

File tree

1 file changed

+14
-2
lines changed
  • cardano-cli/src/Cardano/CLI/EraBased/Query

1 file changed

+14
-2
lines changed

cardano-cli/src/Cardano/CLI/EraBased/Query/Run.hs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,7 @@ runQuerySPOStakeDistribution
17991799
, Cmd.target
18001800
}
18011801
, Cmd.spoHashSources = spoHashSources'
1802+
, Cmd.outputFormat
18021803
, Cmd.mOutFile
18031804
} = conwayEraOnwardsConstraints eon $ do
18041805
let spoFromSource = firstExceptT QueryCmdSPOKeyError . readSPOCredential
@@ -1845,15 +1846,26 @@ runQuerySPOStakeDistribution
18451846
)
18461847
(Map.keys addressesAndRewards)
18471848

1848-
let toWrite =
1849+
let json =
18491850
[ ( spo
18501851
, coin
18511852
, Map.lookup spo spoToDelegatee
18521853
)
18531854
| (spo, coin) <- Map.assocs spoStakeDistribution
18541855
]
18551856

1856-
writeOutput mOutFile toWrite
1857+
output =
1858+
outputFormat
1859+
& ( id
1860+
. Vary.on (\FormatJson -> Json.encodeJson)
1861+
. Vary.on (\FormatYaml -> Json.encodeYaml)
1862+
$ Vary.exhaustiveCase
1863+
)
1864+
$ json
1865+
1866+
firstExceptT QueryCmdWriteFileError
1867+
. newExceptT
1868+
$ writeLazyByteStringOutput mOutFile output
18571869

18581870
runQueryCommitteeMembersState
18591871
:: Cmd.QueryCommitteeMembersStateCmdArgs era

0 commit comments

Comments
 (0)