{-# LANGUAGE LambdaCase #-}

module Cardano.CLI.Run.Debug
  ( DebugCmdError (..)
  , runLogEpochStateCmd
  , runDebugCmds
  )
where

import           Cardano.Api

import           Cardano.CLI.Commands.Debug
import           Cardano.CLI.Run.Debug.CheckNodeConfiguration (runCheckNodeConfig)
import           Cardano.CLI.Run.Debug.LogEpochState
import           Cardano.CLI.Run.Debug.TransactionView (runTransactionViewCmd)
import           Cardano.CLI.Types.Errors.DebugCmdError

runDebugCmds :: DebugCmds -> ExceptT DebugCmdError IO ()
runDebugCmds :: DebugCmds -> ExceptT DebugCmdError IO ()
runDebugCmds = \case
  DebugCheckNodeConfigurationCmd CheckNodeConfigCmdArgs
cmd -> CheckNodeConfigCmdArgs -> ExceptT DebugCmdError IO ()
runCheckNodeConfig CheckNodeConfigCmdArgs
cmd
  DebugLogEpochStateCmd LogEpochStateCmdArgs
cmd -> IO () -> ExceptT DebugCmdError IO ()
forall a. IO a -> ExceptT DebugCmdError IO a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> ExceptT DebugCmdError IO ())
-> IO () -> ExceptT DebugCmdError IO ()
forall a b. (a -> b) -> a -> b
$ LogEpochStateCmdArgs -> IO ()
runLogEpochStateCmd LogEpochStateCmdArgs
cmd
  DebugTransactionViewCmd TransactionViewCmdArgs
cmd -> (TxCmdError -> DebugCmdError)
-> ExceptT TxCmdError IO () -> ExceptT DebugCmdError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT TxCmdError -> DebugCmdError
DebugTxCmdError (ExceptT TxCmdError IO () -> ExceptT DebugCmdError IO ())
-> ExceptT TxCmdError IO () -> ExceptT DebugCmdError IO ()
forall a b. (a -> b) -> a -> b
$ TransactionViewCmdArgs -> ExceptT TxCmdError IO ()
runTransactionViewCmd TransactionViewCmdArgs
cmd