diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs index 05def8f92e..f649f06a4b 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs @@ -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 ] diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs index 61f41f87da..2f9b1aeb9d 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs @@ -24,10 +24,10 @@ 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 @@ -35,10 +35,10 @@ pGovernanceCmds envCli era = ] ) [ 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 ] diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs index 455aa47886..24301da729 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs @@ -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 @@ -36,7 +36,7 @@ pGovernanceDRepCmds envCli era = ) [ pGovernanceDRepKeyGenCmd era , pGovernanceDRepKeyIdCmd era - , pRegistrationCertificateCmd envCli era + , pRegistrationCertificateCmd era envCli ] pGovernanceDRepKeyGenCmd :: () @@ -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" diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Query.hs index cc28b1229d..23d11636e1 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Query.hs @@ -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" @@ -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" @@ -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" @@ -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" diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs index d312f8410e..0bc6f5a84c 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs @@ -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 @@ -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)" @@ -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 diff --git a/cardano-cli/src/Cardano/CLI/Options.hs b/cardano-cli/src/Cardano/CLI/Options.hs index 3de0e632d8..48b901ceac 100644 --- a/cardano-cli/src/Cardano/CLI/Options.hs +++ b/cardano-cli/src/Cardano/CLI/Options.hs @@ -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