{-# LANGUAGE LambdaCase #-}

module Cardano.CLI.Legacy.Run
  ( runLegacyCmds
  )
where

import           Cardano.CLI.Legacy.Options
import           Cardano.CLI.Legacy.Run.Genesis
import           Cardano.CLI.Legacy.Run.Governance
import           Cardano.CLI.Types.Errors.CmdError

import           Control.Monad.Trans.Except (ExceptT)
import           Control.Monad.Trans.Except.Extra (firstExceptT)

runLegacyCmds :: LegacyCmds -> ExceptT CmdError IO ()
runLegacyCmds :: LegacyCmds -> ExceptT CmdError IO ()
runLegacyCmds = \case
  LegacyGenesisCmds LegacyGenesisCmds
cmd -> (GenesisCmdError -> CmdError)
-> ExceptT GenesisCmdError IO () -> ExceptT CmdError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT GenesisCmdError -> CmdError
CmdGenesisError (ExceptT GenesisCmdError IO () -> ExceptT CmdError IO ())
-> ExceptT GenesisCmdError IO () -> ExceptT CmdError IO ()
forall a b. (a -> b) -> a -> b
$ LegacyGenesisCmds -> ExceptT GenesisCmdError IO ()
runLegacyGenesisCmds LegacyGenesisCmds
cmd
  LegacyGovernanceCmds LegacyGovernanceCmds
cmd -> (GovernanceCmdError -> CmdError)
-> ExceptT GovernanceCmdError IO () -> ExceptT CmdError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT GovernanceCmdError -> CmdError
CmdGovernanceCmdError (ExceptT GovernanceCmdError IO () -> ExceptT CmdError IO ())
-> ExceptT GovernanceCmdError IO () -> ExceptT CmdError IO ()
forall a b. (a -> b) -> a -> b
$ LegacyGovernanceCmds -> ExceptT GovernanceCmdError IO ()
runLegacyGovernanceCmds LegacyGovernanceCmds
cmd