-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
168 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
cardano-cli/src/Cardano/CLI/EraBased/Commands/TopLevelCommands.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
|
||
module Cardano.CLI.EraBased.Commands.TopLevelCommands | ||
( AnyEraCommand (..) | ||
, Cmds (..) | ||
, renderAnyEraCommand | ||
, renderCmds | ||
) | ||
where | ||
|
||
import Cardano.Api (ShelleyBasedEra (..)) | ||
|
||
import Cardano.CLI.Commands.Address | ||
import Cardano.CLI.Commands.Key | ||
import Cardano.CLI.Commands.Node | ||
import Cardano.CLI.EraBased.Commands.Genesis | ||
import Cardano.CLI.EraBased.Commands.Query | ||
import Cardano.CLI.EraBased.Commands.StakeAddress | ||
import Cardano.CLI.EraBased.Commands.StakePool | ||
import Cardano.CLI.EraBased.Commands.TextView | ||
import Cardano.CLI.EraBased.Commands.Transaction | ||
|
||
import Cardano.CLI.EraBased.Options.Governance (GovernanceCmds, | ||
renderGovernanceCmds) | ||
|
||
import Data.Text (Text) | ||
import Data.Typeable (Typeable) | ||
|
||
|
||
-- TODO: ShelleyBasedEra era is not needed in AnyEraCommandOf | ||
data AnyEraCommand where | ||
AnyEraCommandOf :: Typeable era => ShelleyBasedEra era -> Cmds era -> AnyEraCommand | ||
|
||
renderAnyEraCommand :: AnyEraCommand -> Text | ||
renderAnyEraCommand = \case | ||
AnyEraCommandOf _ cmd -> renderCmds cmd | ||
|
||
data Cmds era | ||
= AddressCmds AddressCmds | ||
| KeyCmds KeyCmds | ||
| GenesisCmds (GenesisCmds era) | ||
| GovernanceCmds (GovernanceCmds era) | ||
| NodeCmds NodeCmds | ||
| QueryCmds (QueryCmds era) | ||
| StakeAddressCmds (StakeAddressCmds era) | ||
| StakePoolCmds (StakePoolCmds era) | ||
| TextViewCmds (TextViewCmds era) | ||
| TransactionCmds (TransactionCmds era) | ||
|
||
renderCmds :: Cmds era -> Text | ||
renderCmds = \case | ||
AddressCmds cmd -> | ||
renderAddressCmds cmd | ||
KeyCmds cmd -> | ||
renderKeyCmds cmd | ||
GenesisCmds cmd -> | ||
renderGenesisCmds cmd | ||
GovernanceCmds cmd -> | ||
renderGovernanceCmds cmd | ||
NodeCmds cmd -> | ||
renderNodeCmds cmd | ||
QueryCmds cmd -> | ||
renderQueryCmds cmd | ||
StakeAddressCmds cmd -> | ||
renderStakeAddressCmds cmd | ||
StakePoolCmds cmd -> | ||
renderStakePoolCmds cmd | ||
TextViewCmds cmd -> | ||
renderTextViewCmds cmd | ||
TransactionCmds cmd -> | ||
renderTransactionCmds cmd | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module Cardano.CLI.EraBased.Options.Era | ||
( pAnyEraCommand | ||
) | ||
where | ||
|
||
import Cardano.Api (ShelleyBasedEra (..)) | ||
|
||
|
||
import Cardano.CLI.Environment | ||
import Cardano.CLI.EraBased.Options.Common | ||
import Cardano.CLI.EraBased.Options.TopLevelCommands | ||
import Cardano.CLI.EraBased.Commands.TopLevelCommands | ||
|
||
import Cardano.CLI.Parser | ||
|
||
import Data.Foldable | ||
|
||
import Options.Applicative (Parser) | ||
import qualified Options.Applicative as Opt | ||
|
||
pAnyEraCommand :: EnvCli -> Parser AnyEraCommand | ||
pAnyEraCommand envCli = | ||
asum | ||
[ -- Note, byron is ommitted because there is already a legacy command group for it. | ||
|
||
subParser "shelley" $ | ||
Opt.info (AnyEraCommandOf ShelleyBasedEraShelley <$> pCmds ShelleyBasedEraShelley envCli) $ | ||
Opt.progDesc ("Shelley era commands" <> deprecationText) | ||
, subParser "allegra" $ | ||
Opt.info (AnyEraCommandOf ShelleyBasedEraAllegra <$> pCmds ShelleyBasedEraAllegra envCli) $ | ||
Opt.progDesc ("Allegra era commands" <> deprecationText) | ||
, subParser "mary" $ | ||
Opt.info (AnyEraCommandOf ShelleyBasedEraMary <$> pCmds ShelleyBasedEraMary envCli) $ | ||
Opt.progDesc ("Mary era commands" <> deprecationText) | ||
, subParser "alonzo" $ | ||
Opt.info (AnyEraCommandOf ShelleyBasedEraAlonzo <$> pCmds ShelleyBasedEraAlonzo envCli) $ | ||
Opt.progDesc ("Alonzo era commands" <> deprecationText) | ||
, subParser "babbage" $ | ||
Opt.info (AnyEraCommandOf ShelleyBasedEraBabbage <$> pCmds ShelleyBasedEraBabbage envCli) $ | ||
Opt.progDesc ("Babbage era commands" <> deprecationText) | ||
, subParser "conway" $ | ||
Opt.info (AnyEraCommandOf ShelleyBasedEraConway <$> pCmds ShelleyBasedEraConway envCli) $ | ||
Opt.progDesc "Conway era commands" | ||
, subParser "latest" $ | ||
Opt.info (AnyEraCommandOf ShelleyBasedEraConway <$> pCmds ShelleyBasedEraConway envCli) $ | ||
Opt.progDesc "Latest era commands (Conway)" | ||
] |
41 changes: 41 additions & 0 deletions
41
cardano-cli/src/Cardano/CLI/EraBased/Options/TopLevelCommands.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module Cardano.CLI.EraBased.Options.TopLevelCommands | ||
( pCmds | ||
) | ||
where | ||
|
||
import Cardano.Api (ShelleyBasedEra (..)) | ||
|
||
import Cardano.CLI.Environment | ||
import Cardano.CLI.EraBased.Options.Genesis | ||
import Cardano.CLI.EraBased.Options.Governance ( pGovernanceCmds | ||
) | ||
import Cardano.CLI.EraBased.Options.Query | ||
import Cardano.CLI.EraBased.Commands.TopLevelCommands | ||
import Cardano.CLI.EraBased.Options.StakeAddress | ||
import Cardano.CLI.EraBased.Options.StakePool | ||
import Cardano.CLI.EraBased.Options.TextView | ||
import Cardano.CLI.EraBased.Options.Transaction | ||
import Cardano.CLI.Options.Address | ||
import Cardano.CLI.Options.Key | ||
import Cardano.CLI.Options.Node | ||
|
||
import Data.Foldable | ||
import Data.Maybe | ||
|
||
import Options.Applicative (Parser) | ||
|
||
pCmds :: ShelleyBasedEra era -> EnvCli -> Parser (Cmds era) | ||
pCmds era envCli = do | ||
asum $ | ||
catMaybes | ||
[ Just (AddressCmds <$> pAddressCmds envCli) | ||
, Just (KeyCmds <$> pKeyCmds) | ||
, fmap GenesisCmds <$> pGenesisCmds era envCli | ||
, fmap GovernanceCmds <$> pGovernanceCmds era | ||
, Just (NodeCmds <$> pNodeCmds) | ||
, fmap QueryCmds <$> pQueryCmds era envCli | ||
, fmap StakeAddressCmds <$> pStakeAddressCmds era envCli | ||
, fmap StakePoolCmds <$> pStakePoolCmds era envCli | ||
, fmap TextViewCmds <$> pTextViewCmds | ||
, fmap TransactionCmds <$> pTransactionCmds era envCli | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters