diff --git a/cardano-cli/src/Cardano/CLI/Run/Legacy/Query.hs b/cardano-cli/src/Cardano/CLI/Run/Legacy/Query.hs index fc0f0dcc4c..91f496d3e5 100644 --- a/cardano-cli/src/Cardano/CLI/Run/Legacy/Query.hs +++ b/cardano-cli/src/Cardano/CLI/Run/Legacy/Query.hs @@ -1426,12 +1426,7 @@ runQueryLeadershipSchedule $ nextEpochEligibleLeadershipSlots sbe shelleyGenesis serCurrentEpochState ptclState poolid vrkSkey bpp eInfo (tip, curentEpoch) - - case mJsonOutputFile of - Nothing -> liftIO $ printLeadershipScheduleAsText schedule eInfo (SystemStart $ sgSystemStart shelleyGenesis) - Just (File jsonOutputFile) -> - liftIO $ LBS.writeFile jsonOutputFile $ - printLeadershipScheduleAsJson schedule eInfo (SystemStart $ sgSystemStart shelleyGenesis) + writeSchedule mJsonOutputFile eInfo shelleyGenesis schedule mode -> pure $ do left . ShelleyQueryCmdUnsupportedMode $ AnyConsensusMode mode @@ -1439,6 +1434,13 @@ runQueryLeadershipSchedule & onLeft (left . ShelleyQueryCmdAcquireFailure) & onLeft left where + writeSchedule mOutFile eInfo shelleyGenesis schedule = + case mOutFile of + Nothing -> liftIO $ printLeadershipScheduleAsText schedule eInfo (SystemStart $ sgSystemStart shelleyGenesis) + Just (File jsonOutputFile) -> + liftIO $ LBS.writeFile jsonOutputFile $ + printLeadershipScheduleAsJson schedule eInfo (SystemStart $ sgSystemStart shelleyGenesis) + printLeadershipScheduleAsText :: Set SlotNo -> EpochInfo (Either Text)