-
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.
Merge pull request #950 from IntersectMBO/jordan/20241022-cleanup
Refactor
- Loading branch information
Showing
19 changed files
with
171 additions
and
235 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 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
This file was deleted.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
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,68 @@ | ||
{-# 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) | ||
|
||
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,44 @@ | ||
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 = | ||
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)" | ||
] |
Oops, something went wrong.