Skip to content

Commit

Permalink
Always put era before envCli
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Sep 19, 2023
1 parent 8a945f7 commit 2e551cb
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 59 deletions.
22 changes: 11 additions & 11 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,40 +88,40 @@ pAnyEraCommand envCli =
[ -- Note, byron is ommitted because there is already a legacy command group for it.

subParser "shelley"
$ Opt.info (AnyEraCommandOf ShelleyBasedEraShelley <$> pCmds envCli ShelleyEra)
$ Opt.info (AnyEraCommandOf ShelleyBasedEraShelley <$> pCmds ShelleyEra envCli)
$ Opt.progDesc "Shelley era commands"
, subParser "allegra"
$ Opt.info (AnyEraCommandOf ShelleyBasedEraAllegra <$> pCmds envCli AllegraEra)
$ Opt.info (AnyEraCommandOf ShelleyBasedEraAllegra <$> pCmds AllegraEra envCli)
$ Opt.progDesc "Allegra era commands"
, subParser "mary"
$ Opt.info (AnyEraCommandOf ShelleyBasedEraMary <$> pCmds envCli MaryEra)
$ Opt.info (AnyEraCommandOf ShelleyBasedEraMary <$> pCmds MaryEra envCli)
$ Opt.progDesc "Mary era commands"
, subParser "alonzo"
$ Opt.info (AnyEraCommandOf ShelleyBasedEraAlonzo <$> pCmds envCli AlonzoEra)
$ Opt.info (AnyEraCommandOf ShelleyBasedEraAlonzo <$> pCmds AlonzoEra envCli)
$ Opt.progDesc "Alonzo era commands"
, subParser "babbage"
$ Opt.info (AnyEraCommandOf ShelleyBasedEraBabbage <$> pCmds envCli BabbageEra)
$ Opt.info (AnyEraCommandOf ShelleyBasedEraBabbage <$> pCmds BabbageEra envCli)
$ Opt.progDesc "Babbage era commands"
, subParser "conway"
$ Opt.info (AnyEraCommandOf ShelleyBasedEraConway <$> pCmds envCli ConwayEra)
$ Opt.info (AnyEraCommandOf ShelleyBasedEraConway <$> pCmds ConwayEra envCli)
$ Opt.progDesc "Conway era commands"

, subParser "latest"
$ Opt.info (AnyEraCommandOf ShelleyBasedEraBabbage <$> pCmds envCli BabbageEra)
$ Opt.info (AnyEraCommandOf ShelleyBasedEraBabbage <$> pCmds BabbageEra envCli)
$ Opt.progDesc "Latest era commands (Babbage)"
]

pCmds :: EnvCli -> CardanoEra era -> Parser (Cmds era)
pCmds envCli era =
pCmds :: CardanoEra era -> EnvCli -> Parser (Cmds era)
pCmds era envCli =
asum $ catMaybes
[ fmap AddressCmds <$> pAddressCmds era envCli
, fmap KeyCmds <$> pKeyCmds
, fmap GenesisCmds <$> pGenesisCmds envCli
, fmap GovernanceCmds <$> pGovernanceCmds envCli era
, fmap GovernanceCmds <$> pGovernanceCmds era envCli
, fmap NodeCmds <$> pNodeCmds
, fmap QueryCmds <$> pQueryCmds envCli
, fmap StakeAddressCmds <$> pStakeAddressCmds era envCli
, fmap StakePoolCmds <$> pStakePoolCmds era envCli
, fmap TextViewCmds <$> pTextViewCmds
, fmap TransactionCmds <$> pTransactionCmds envCli era
, fmap TransactionCmds <$> pTransactionCmds era envCli
]
10 changes: 5 additions & 5 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ import Options.Applicative
import qualified Options.Applicative as Opt

pGovernanceCmds :: ()
=> EnvCli
-> CardanoEra era
=> CardanoEra era
-> EnvCli
-> Maybe (Parser (GovernanceCmds era))
pGovernanceCmds envCli era =
pGovernanceCmds era envCli =
subInfoParser "governance"
( Opt.progDesc
$ mconcat
[ "Governance commands."
]
)
[ pCreateMirCertificatesCmds era
, fmap GovernanceQueryCmds <$> pGovernanceQueryCmds envCli era
, fmap GovernanceQueryCmds <$> pGovernanceQueryCmds era envCli
, fmap GovernanceActionCmds <$> pGovernanceActionCmds era
, fmap GovernanceCommitteeCmds <$> pGovernanceCommitteeCmds era
, fmap GovernanceDRepCmds <$> pGovernanceDRepCmds envCli era
, fmap GovernanceDRepCmds <$> pGovernanceDRepCmds era envCli
, fmap GovernanceVoteCmds <$> pGovernanceVoteCmds era
]

Expand Down
14 changes: 7 additions & 7 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import Options.Applicative (Parser)
import qualified Options.Applicative as Opt

pGovernanceDRepCmds :: ()
=> EnvCli
-> CardanoEra era
=> CardanoEra era
-> EnvCli
-> Maybe (Parser (GovernanceDRepCmds era))
pGovernanceDRepCmds envCli era =
pGovernanceDRepCmds era envCli =
subInfoParser "drep"
( Opt.progDesc
$ mconcat
Expand All @@ -36,7 +36,7 @@ pGovernanceDRepCmds envCli era =
)
[ pGovernanceDRepKeyGenCmd era
, pGovernanceDRepKeyIdCmd era
, pRegistrationCertificateCmd envCli era
, pRegistrationCertificateCmd era envCli
]

pGovernanceDRepKeyGenCmd :: ()
Expand Down Expand Up @@ -83,10 +83,10 @@ pDRepIdOutputFormat =
-- Registration Certificate related

pRegistrationCertificateCmd :: ()
=> EnvCli
-> CardanoEra era
=> CardanoEra era
-> EnvCli
-> Maybe (Parser (GovernanceDRepCmds era))
pRegistrationCertificateCmd envCli era = do
pRegistrationCertificateCmd era envCli = do
w <- maybeFeatureInEra era
pure
$ subParser "registration-certificate"
Expand Down
59 changes: 29 additions & 30 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,36 @@ import Cardano.CLI.EraBased.Options.Common
import Options.Applicative
import qualified Options.Applicative as Opt

pGovernanceQueryCmds
:: ()
=> EnvCli
-> CardanoEra era
pGovernanceQueryCmds :: ()
=> CardanoEra era
-> EnvCli
-> Maybe (Parser (GovernanceQueryCmds era))
pGovernanceQueryCmds env era =
pGovernanceQueryCmds era env =
subInfoParser "query"
( Opt.progDesc "Query governance-related information" )
[ pGovernanceQueryGetConstitutionCmd env era
, pGovernanceQueryGetGovStateCmd env era
, pGovernanceQueryDRepStateCmd env era
, pGovernanceQueryDRepStakeDistributionCmd env era
, pGovernanceQueryGetCommitteeStateCmd env era
[ pGovernanceQueryGetConstitutionCmd era env
, pGovernanceQueryGetGovStateCmd era env
, pGovernanceQueryDRepStateCmd era env
, pGovernanceQueryDRepStakeDistributionCmd era env
, pGovernanceQueryGetCommitteeStateCmd era env
]

pGovernanceQueryGetConstitutionCmd
:: EnvCli
-> CardanoEra era
pGovernanceQueryGetConstitutionCmd :: ()
=> CardanoEra era
-> EnvCli
-> Maybe (Parser (GovernanceQueryCmds era))
pGovernanceQueryGetConstitutionCmd env era = do
pGovernanceQueryGetConstitutionCmd era env = do
cOn <- maybeFeatureInEra era
pure
$ subParser "constitution"
$ Opt.info (GovernanceQueryConstitutionCmd cOn <$> pNoArgQueryCmd env)
$ Opt.progDesc "Get the constitution"

pGovernanceQueryGetGovStateCmd
:: EnvCli
-> CardanoEra era
pGovernanceQueryGetGovStateCmd :: ()
=> CardanoEra era
-> EnvCli
-> Maybe (Parser (GovernanceQueryCmds era))
pGovernanceQueryGetGovStateCmd env era = do
pGovernanceQueryGetGovStateCmd era env = do
cOn <- maybeFeatureInEra era
pure
$ subParser "gov-state"
Expand All @@ -56,11 +55,11 @@ pGovernanceQueryGetGovStateCmd env era = do
-- What about 'DRep c' - this means that only 'KeyHash' constructor is in use here: should also
-- 'DRepAlwaysAbstain' and 'DRepAlwaysNoConfidence' be supported here?

pGovernanceQueryDRepStateCmd
:: EnvCli
-> CardanoEra era
pGovernanceQueryDRepStateCmd :: ()
=> CardanoEra era
-> EnvCli
-> Maybe (Parser (GovernanceQueryCmds era))
pGovernanceQueryDRepStateCmd env era = do
pGovernanceQueryDRepStateCmd era env = do
cOn <- maybeFeatureInEra era
pure
$ subParser "drep-state"
Expand All @@ -75,11 +74,11 @@ pGovernanceQueryDRepStateCmd env era = do
<*> some pDRepVerificationKeyOrHashOrFile
<*> optional pOutputFile

pGovernanceQueryDRepStakeDistributionCmd
:: EnvCli
-> CardanoEra era
pGovernanceQueryDRepStakeDistributionCmd :: ()
=> CardanoEra era
-> EnvCli
-> Maybe (Parser (GovernanceQueryCmds era))
pGovernanceQueryDRepStakeDistributionCmd env era = do
pGovernanceQueryDRepStakeDistributionCmd era env = do
cOn <- maybeFeatureInEra era
pure
$ subParser "drep-stake-distribution"
Expand All @@ -94,11 +93,11 @@ pGovernanceQueryDRepStakeDistributionCmd env era = do
<*> some pDRepVerificationKeyOrHashOrFile
<*> optional pOutputFile

pGovernanceQueryGetCommitteeStateCmd
:: EnvCli
-> CardanoEra era
pGovernanceQueryGetCommitteeStateCmd :: ()
=> CardanoEra era
-> EnvCli
-> Maybe (Parser (GovernanceQueryCmds era))
pGovernanceQueryGetCommitteeStateCmd env era = do
pGovernanceQueryGetCommitteeStateCmd era env = do
cOn <- maybeFeatureInEra era
pure
$ subParser "committee-state"
Expand Down
13 changes: 8 additions & 5 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ import Prettyprinter (line, pretty)
{- HLINT ignore "Use <$>" -}
{- HLINT ignore "Move brackets to avoid $" -}

pTransactionCmds :: EnvCli -> CardanoEra era -> Maybe (Parser (TransactionCmds era))
pTransactionCmds envCli era =
pTransactionCmds :: ()
=> CardanoEra era
-> EnvCli
-> Maybe (Parser (TransactionCmds era))
pTransactionCmds era envCli =
subInfoParser "transaction"
( Opt.progDesc
$ mconcat
Expand All @@ -47,7 +50,7 @@ pTransactionCmds envCli era =
]
, Just
$ subParser "build"
$ Opt.info (pTransactionBuild envCli era)
$ Opt.info (pTransactionBuild era envCli)
$ Opt.progDescDoc
$ Just $ mconcat
[ pretty @String "Build a balanced transaction (automatically calculates fees)"
Expand Down Expand Up @@ -146,8 +149,8 @@ pScriptValidity = asum
]
]

pTransactionBuild :: EnvCli -> CardanoEra era -> Parser (TransactionCmds era)
pTransactionBuild envCli era =
pTransactionBuild :: CardanoEra era -> EnvCli -> Parser (TransactionCmds era)
pTransactionBuild era envCli =
TxBuild era
<$> pSocketPath envCli
<*> pConsensusModeParams
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ parseLegacy envCli =

_parseTopLevelLatest :: EnvCli -> Parser ClientCommand
_parseTopLevelLatest envCli =
AnyEraCommand . AnyEraCommandOf ShelleyBasedEraBabbage <$> pCmds envCli BabbageEra
AnyEraCommand . AnyEraCommandOf ShelleyBasedEraBabbage <$> pCmds BabbageEra envCli

-- | Parse Legacy commands at the top level of the CLI.
parseTopLevelLegacy :: EnvCli -> Parser ClientCommand
Expand Down

0 comments on commit 2e551cb

Please sign in to comment.