From 6483900e7ae3d61498de0fc9efab89cc51ae55a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Tue, 20 Aug 2024 15:54:42 +0200 Subject: [PATCH] Move away from Opt.auto in EraBased/Options/Common.hs --- .../Cardano/CLI/EraBased/Options/Common.hs | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index 52a992a77d..a81589b67d 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -4,6 +4,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TupleSections #-} {-# LANGUAGE TypeApplications #-} {- HLINT ignore "Move brackets to avoid $" -} @@ -1238,7 +1239,7 @@ pScriptWitnessFiles sbe witctx autoBalanceExecUnits scriptFlagPrefix scriptFlagP pExecutionUnits :: String -> Parser ExecutionUnits pExecutionUnits scriptFlagPrefix = fmap (uncurry ExecutionUnits) $ - Opt.option Opt.auto $ + Opt.option ((,) <$> integralReader <*> integralReader) $ mconcat [ Opt.long (scriptFlagPrefix ++ "-execution-units") , Opt.metavar "(INT, INT)" @@ -2327,7 +2328,7 @@ pTotalCollateral = pWitnessOverride :: Parser Word pWitnessOverride = - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "witness-override" , Opt.metavar "WORD" @@ -2336,7 +2337,7 @@ pWitnessOverride = pNumberOfShelleyKeyWitnesses :: Parser Int pNumberOfShelleyKeyWitnesses = - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "shelley-key-witnesses" , Opt.metavar "INT" @@ -2345,7 +2346,7 @@ pNumberOfShelleyKeyWitnesses = pNumberOfByronKeyWitnesses :: Parser Int pNumberOfByronKeyWitnesses = - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "byron-key-witnesses" , Opt.metavar "Int" @@ -2609,7 +2610,7 @@ pInvalidHereafter eon = pTxFee :: Parser Lovelace pTxFee = fmap (L.Coin . (fromIntegral :: Natural -> Integer)) $ - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "fee" , Opt.metavar "LOVELACE" @@ -2695,7 +2696,7 @@ pInputTxOrTxBodyFile = pTxInCountDeprecated :: Parser TxInCount pTxInCountDeprecated = fmap TxInCount $ - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "tx-in-count" , Opt.metavar "NATURAL" @@ -2705,7 +2706,7 @@ pTxInCountDeprecated = pTxOutCountDeprecated :: Parser TxOutCount pTxOutCountDeprecated = fmap TxOutCount $ - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "tx-out-count" , Opt.metavar "NATURAL" @@ -2715,7 +2716,7 @@ pTxOutCountDeprecated = pTxShelleyWitnessCount :: Parser TxShelleyWitnessCount pTxShelleyWitnessCount = fmap TxShelleyWitnessCount $ - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "witness-count" , Opt.metavar "NATURAL" @@ -2725,7 +2726,7 @@ pTxShelleyWitnessCount = pTxByronWitnessCount :: Parser TxByronWitnessCount pTxByronWitnessCount = fmap TxByronWitnessCount $ - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "byron-witness-count" , Opt.metavar "NATURAL" @@ -3167,7 +3168,7 @@ pMinPoolCost = pMaxBodySize :: Parser Word32 pMaxBodySize = - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "max-block-body-size" , Opt.metavar "WORD32" @@ -3176,7 +3177,7 @@ pMaxBodySize = pMaxTransactionSize :: Parser Word32 pMaxTransactionSize = - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "max-tx-size" , Opt.metavar "WORD32" @@ -3253,7 +3254,7 @@ pEpochBoundRetirement = pNumberOfPools :: Parser Natural pNumberOfPools = - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "number-of-pools" , Opt.metavar "NATURAL" @@ -3363,7 +3364,7 @@ pMaxTxExecutionUnits :: Parser ExecutionUnits pMaxTxExecutionUnits = uncurry ExecutionUnits <$> Opt.option - Opt.auto + ((,) <$> integralReader <*> integralReader) ( mconcat [ Opt.long "max-tx-execution-units" , Opt.metavar "(INT, INT)" @@ -3379,7 +3380,7 @@ pMaxBlockExecutionUnits :: Parser ExecutionUnits pMaxBlockExecutionUnits = uncurry ExecutionUnits <$> Opt.option - Opt.auto + ((,) <$> integralReader <*> integralReader) ( mconcat [ Opt.long "max-block-execution-units" , Opt.metavar "(INT, INT)" @@ -3393,7 +3394,7 @@ pMaxBlockExecutionUnits = pMaxValueSize :: Parser Natural pMaxValueSize = - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "max-value-size" , Opt.metavar "INT" @@ -3405,7 +3406,7 @@ pMaxValueSize = pCollateralPercent :: Parser Natural pCollateralPercent = - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "collateral-percent" , Opt.metavar "INT" @@ -3419,7 +3420,7 @@ pCollateralPercent = pMaxCollateralInputs :: Parser Natural pMaxCollateralInputs = - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "max-collateral-inputs" , Opt.metavar "INT" @@ -3435,14 +3436,14 @@ pProtocolVersion = (,) <$> pProtocolMajorVersion <*> pProtocolMinorVersion where pProtocolMajorVersion = - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "protocol-major-version" , Opt.metavar "NATURAL" , Opt.help "Major protocol version. An increase indicates a hard fork." ] pProtocolMinorVersion = - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "protocol-minor-version" , Opt.metavar "NATURAL" @@ -3592,7 +3593,7 @@ pDRepVotingThresholds = pMinCommitteeSize :: Parser Natural pMinCommitteeSize = - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "min-committee-size" , Opt.metavar "INT" @@ -3962,7 +3963,7 @@ pNetworkIdForTestnetData envCli = pReferenceScriptSize :: Parser ReferenceScriptSize pReferenceScriptSize = fmap ReferenceScriptSize $ - Opt.option Opt.auto $ + Opt.option integralReader $ mconcat [ Opt.long "reference-script-size" , Opt.metavar "NATURAL"