module Cardano.CLI.EraBased.Options.Era
  ( pAnyEraCommand
  )
where

import           Cardano.Api (ShelleyBasedEra (..))

import           Cardano.CLI.Environment
import           Cardano.CLI.EraBased.Commands.TopLevelCommands
import           Cardano.CLI.EraBased.Options.Common
import           Cardano.CLI.EraBased.Options.TopLevelCommands
import           Cardano.CLI.Parser

import           Data.Foldable
import           Options.Applicative (Parser)
import qualified Options.Applicative as Opt

pAnyEraCommand :: EnvCli -> Parser AnyEraCommand
pAnyEraCommand :: EnvCli -> Parser AnyEraCommand
pAnyEraCommand EnvCli
envCli =
  [Parser AnyEraCommand] -> Parser AnyEraCommand
forall (t :: * -> *) (f :: * -> *) a.
(Foldable t, Alternative f) =>
t (f a) -> f a
asum
    [ -- Note, byron is ommitted because there is already a legacy command group for it.

      String -> ParserInfo AnyEraCommand -> Parser AnyEraCommand
forall a. String -> ParserInfo a -> Parser a
subParser String
"shelley" (ParserInfo AnyEraCommand -> Parser AnyEraCommand)
-> ParserInfo AnyEraCommand -> Parser AnyEraCommand
forall a b. (a -> b) -> a -> b
$
        Parser AnyEraCommand
-> InfoMod AnyEraCommand -> ParserInfo AnyEraCommand
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (ShelleyBasedEra ShelleyEra -> Cmds ShelleyEra -> AnyEraCommand
forall era.
Typeable era =>
ShelleyBasedEra era -> Cmds era -> AnyEraCommand
AnyEraCommandOf ShelleyBasedEra ShelleyEra
ShelleyBasedEraShelley (Cmds ShelleyEra -> AnyEraCommand)
-> Parser (Cmds ShelleyEra) -> Parser AnyEraCommand
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ShelleyBasedEra ShelleyEra -> EnvCli -> Parser (Cmds ShelleyEra)
forall era. ShelleyBasedEra era -> EnvCli -> Parser (Cmds era)
pCmds ShelleyBasedEra ShelleyEra
ShelleyBasedEraShelley EnvCli
envCli) (InfoMod AnyEraCommand -> ParserInfo AnyEraCommand)
-> InfoMod AnyEraCommand -> ParserInfo AnyEraCommand
forall a b. (a -> b) -> a -> b
$
          String -> InfoMod AnyEraCommand
forall a. String -> InfoMod a
Opt.progDesc (String
"Shelley era commands" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
deprecationText)
    , String -> ParserInfo AnyEraCommand -> Parser AnyEraCommand
forall a. String -> ParserInfo a -> Parser a
subParser String
"allegra" (ParserInfo AnyEraCommand -> Parser AnyEraCommand)
-> ParserInfo AnyEraCommand -> Parser AnyEraCommand
forall a b. (a -> b) -> a -> b
$
        Parser AnyEraCommand
-> InfoMod AnyEraCommand -> ParserInfo AnyEraCommand
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (ShelleyBasedEra AllegraEra -> Cmds AllegraEra -> AnyEraCommand
forall era.
Typeable era =>
ShelleyBasedEra era -> Cmds era -> AnyEraCommand
AnyEraCommandOf ShelleyBasedEra AllegraEra
ShelleyBasedEraAllegra (Cmds AllegraEra -> AnyEraCommand)
-> Parser (Cmds AllegraEra) -> Parser AnyEraCommand
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ShelleyBasedEra AllegraEra -> EnvCli -> Parser (Cmds AllegraEra)
forall era. ShelleyBasedEra era -> EnvCli -> Parser (Cmds era)
pCmds ShelleyBasedEra AllegraEra
ShelleyBasedEraAllegra EnvCli
envCli) (InfoMod AnyEraCommand -> ParserInfo AnyEraCommand)
-> InfoMod AnyEraCommand -> ParserInfo AnyEraCommand
forall a b. (a -> b) -> a -> b
$
          String -> InfoMod AnyEraCommand
forall a. String -> InfoMod a
Opt.progDesc (String
"Allegra era commands" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
deprecationText)
    , String -> ParserInfo AnyEraCommand -> Parser AnyEraCommand
forall a. String -> ParserInfo a -> Parser a
subParser String
"mary" (ParserInfo AnyEraCommand -> Parser AnyEraCommand)
-> ParserInfo AnyEraCommand -> Parser AnyEraCommand
forall a b. (a -> b) -> a -> b
$
        Parser AnyEraCommand
-> InfoMod AnyEraCommand -> ParserInfo AnyEraCommand
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (ShelleyBasedEra MaryEra -> Cmds MaryEra -> AnyEraCommand
forall era.
Typeable era =>
ShelleyBasedEra era -> Cmds era -> AnyEraCommand
AnyEraCommandOf ShelleyBasedEra MaryEra
ShelleyBasedEraMary (Cmds MaryEra -> AnyEraCommand)
-> Parser (Cmds MaryEra) -> Parser AnyEraCommand
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ShelleyBasedEra MaryEra -> EnvCli -> Parser (Cmds MaryEra)
forall era. ShelleyBasedEra era -> EnvCli -> Parser (Cmds era)
pCmds ShelleyBasedEra MaryEra
ShelleyBasedEraMary EnvCli
envCli) (InfoMod AnyEraCommand -> ParserInfo AnyEraCommand)
-> InfoMod AnyEraCommand -> ParserInfo AnyEraCommand
forall a b. (a -> b) -> a -> b
$
          String -> InfoMod AnyEraCommand
forall a. String -> InfoMod a
Opt.progDesc (String
"Mary era commands" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
deprecationText)
    , String -> ParserInfo AnyEraCommand -> Parser AnyEraCommand
forall a. String -> ParserInfo a -> Parser a
subParser String
"alonzo" (ParserInfo AnyEraCommand -> Parser AnyEraCommand)
-> ParserInfo AnyEraCommand -> Parser AnyEraCommand
forall a b. (a -> b) -> a -> b
$
        Parser AnyEraCommand
-> InfoMod AnyEraCommand -> ParserInfo AnyEraCommand
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (ShelleyBasedEra AlonzoEra -> Cmds AlonzoEra -> AnyEraCommand
forall era.
Typeable era =>
ShelleyBasedEra era -> Cmds era -> AnyEraCommand
AnyEraCommandOf ShelleyBasedEra AlonzoEra
ShelleyBasedEraAlonzo (Cmds AlonzoEra -> AnyEraCommand)
-> Parser (Cmds AlonzoEra) -> Parser AnyEraCommand
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ShelleyBasedEra AlonzoEra -> EnvCli -> Parser (Cmds AlonzoEra)
forall era. ShelleyBasedEra era -> EnvCli -> Parser (Cmds era)
pCmds ShelleyBasedEra AlonzoEra
ShelleyBasedEraAlonzo EnvCli
envCli) (InfoMod AnyEraCommand -> ParserInfo AnyEraCommand)
-> InfoMod AnyEraCommand -> ParserInfo AnyEraCommand
forall a b. (a -> b) -> a -> b
$
          String -> InfoMod AnyEraCommand
forall a. String -> InfoMod a
Opt.progDesc (String
"Alonzo era commands" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
deprecationText)
    , String -> ParserInfo AnyEraCommand -> Parser AnyEraCommand
forall a. String -> ParserInfo a -> Parser a
subParser String
"babbage" (ParserInfo AnyEraCommand -> Parser AnyEraCommand)
-> ParserInfo AnyEraCommand -> Parser AnyEraCommand
forall a b. (a -> b) -> a -> b
$
        Parser AnyEraCommand
-> InfoMod AnyEraCommand -> ParserInfo AnyEraCommand
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (ShelleyBasedEra BabbageEra -> Cmds BabbageEra -> AnyEraCommand
forall era.
Typeable era =>
ShelleyBasedEra era -> Cmds era -> AnyEraCommand
AnyEraCommandOf ShelleyBasedEra BabbageEra
ShelleyBasedEraBabbage (Cmds BabbageEra -> AnyEraCommand)
-> Parser (Cmds BabbageEra) -> Parser AnyEraCommand
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ShelleyBasedEra BabbageEra -> EnvCli -> Parser (Cmds BabbageEra)
forall era. ShelleyBasedEra era -> EnvCli -> Parser (Cmds era)
pCmds ShelleyBasedEra BabbageEra
ShelleyBasedEraBabbage EnvCli
envCli) (InfoMod AnyEraCommand -> ParserInfo AnyEraCommand)
-> InfoMod AnyEraCommand -> ParserInfo AnyEraCommand
forall a b. (a -> b) -> a -> b
$
          String -> InfoMod AnyEraCommand
forall a. String -> InfoMod a
Opt.progDesc (String
"Babbage era commands" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
deprecationText)
    , String -> ParserInfo AnyEraCommand -> Parser AnyEraCommand
forall a. String -> ParserInfo a -> Parser a
subParser String
"conway" (ParserInfo AnyEraCommand -> Parser AnyEraCommand)
-> ParserInfo AnyEraCommand -> Parser AnyEraCommand
forall a b. (a -> b) -> a -> b
$
        Parser AnyEraCommand
-> InfoMod AnyEraCommand -> ParserInfo AnyEraCommand
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (ShelleyBasedEra ConwayEra -> Cmds ConwayEra -> AnyEraCommand
forall era.
Typeable era =>
ShelleyBasedEra era -> Cmds era -> AnyEraCommand
AnyEraCommandOf ShelleyBasedEra ConwayEra
ShelleyBasedEraConway (Cmds ConwayEra -> AnyEraCommand)
-> Parser (Cmds ConwayEra) -> Parser AnyEraCommand
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ShelleyBasedEra ConwayEra -> EnvCli -> Parser (Cmds ConwayEra)
forall era. ShelleyBasedEra era -> EnvCli -> Parser (Cmds era)
pCmds ShelleyBasedEra ConwayEra
ShelleyBasedEraConway EnvCli
envCli) (InfoMod AnyEraCommand -> ParserInfo AnyEraCommand)
-> InfoMod AnyEraCommand -> ParserInfo AnyEraCommand
forall a b. (a -> b) -> a -> b
$
          String -> InfoMod AnyEraCommand
forall a. String -> InfoMod a
Opt.progDesc String
"Conway era commands"
    , String -> ParserInfo AnyEraCommand -> Parser AnyEraCommand
forall a. String -> ParserInfo a -> Parser a
subParser String
"latest" (ParserInfo AnyEraCommand -> Parser AnyEraCommand)
-> ParserInfo AnyEraCommand -> Parser AnyEraCommand
forall a b. (a -> b) -> a -> b
$
        Parser AnyEraCommand
-> InfoMod AnyEraCommand -> ParserInfo AnyEraCommand
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (ShelleyBasedEra ConwayEra -> Cmds ConwayEra -> AnyEraCommand
forall era.
Typeable era =>
ShelleyBasedEra era -> Cmds era -> AnyEraCommand
AnyEraCommandOf ShelleyBasedEra ConwayEra
ShelleyBasedEraConway (Cmds ConwayEra -> AnyEraCommand)
-> Parser (Cmds ConwayEra) -> Parser AnyEraCommand
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ShelleyBasedEra ConwayEra -> EnvCli -> Parser (Cmds ConwayEra)
forall era. ShelleyBasedEra era -> EnvCli -> Parser (Cmds era)
pCmds ShelleyBasedEra ConwayEra
ShelleyBasedEraConway EnvCli
envCli) (InfoMod AnyEraCommand -> ParserInfo AnyEraCommand)
-> InfoMod AnyEraCommand -> ParserInfo AnyEraCommand
forall a b. (a -> b) -> a -> b
$
          String -> InfoMod AnyEraCommand
forall a. String -> InfoMod a
Opt.progDesc String
"Latest era commands (Conway)"
    ]