Skip to content

Commit

Permalink
Fix consistency of cli --blah-script-file flag names
Browse files Browse the repository at this point in the history
We have --tx-in and --mint so the corresponding script flags should be
called --tx-in-script-file and --mint-script-file to match.

For backwards compat we keep the old names as hidden aliases.
  • Loading branch information
dcoutts committed Jun 8, 2021
1 parent 478c070 commit ba31337
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs
Expand Up @@ -165,12 +165,16 @@ pAddressCmd =
pPaymentVerifier :: Parser PaymentVerifier
pPaymentVerifier =
PaymentVerifierKey <$> pPaymentVerificationKeyTextOrFile
<|> PaymentVerifierScriptFile <$> pScriptFor "payment-script-file" "Filepath of the payment script."
<|> PaymentVerifierScriptFile <$>
pScriptFor "payment-script-file" Nothing
"Filepath of the payment script."

pStakeVerifier :: Parser StakeVerifier
pStakeVerifier =
StakeVerifierKey <$> pStakeVerificationKeyOrFile
<|> StakeVerifierScriptFile <$> pScriptFor "stake-script-file" "Filepath of the staking script."
<|> StakeVerifierScriptFile <$>
pScriptFor "stake-script-file" Nothing
"Filepath of the staking script."

pPaymentVerificationKeyTextOrFile :: Parser VerificationKeyTextOrFile
pPaymentVerificationKeyTextOrFile =
Expand Down Expand Up @@ -203,24 +207,34 @@ pPaymentVerificationKeyFile =
)

pScript :: Parser ScriptFile
pScript = pScriptFor "script-file" "Filepath of the script."

pScriptFor :: String -> String -> Parser ScriptFile
pScriptFor name help = ScriptFile <$> Opt.strOption
( Opt.long name
<> Opt.metavar "FILE"
<> Opt.help help
<> Opt.completer (Opt.bashCompleter "file")
)
pScript = pScriptFor "script-file" Nothing "Filepath of the script."

pScriptFor :: String -> Maybe String -> String -> Parser ScriptFile
pScriptFor name Nothing help =
ScriptFile <$> Opt.strOption
( Opt.long name
<> Opt.metavar "FILE"
<> Opt.help help
<> Opt.completer (Opt.bashCompleter "file")
)

pScriptFor name (Just deprecated) help =
pScriptFor name Nothing help
<|> ScriptFile <$> Opt.strOption
( Opt.long deprecated
<> Opt.internal
)

pScriptWitnessFiles :: forall witctx.
WitCtx witctx
-> String
-> Maybe String
-> String
-> Parser (ScriptWitnessFiles witctx)
pScriptWitnessFiles witctx scriptFlagPrefix help =
pScriptWitnessFiles witctx scriptFlagPrefix scriptFlagPrefixDeprecated help =
toScriptWitnessFiles
<$> pScriptFor (scriptFlagPrefix ++ "-script-file")
((++ "-script-file") <$> scriptFlagPrefixDeprecated)
("The file containing the script to witness " ++ help)
<*> optional ((,,) <$> pScriptDatumOrFile
<*> pScriptRedeemerOrFile
Expand Down Expand Up @@ -586,6 +600,7 @@ pTransaction =
<*> pTxMetadataJsonSchema
<*> many (pScriptFor
"auxiliary-script-file"
Nothing
"Filepath of auxiliary script(s)")
<*> many pMetadataFile
<*> optional pProtocolParamsSourceSpec
Expand Down Expand Up @@ -1167,7 +1182,7 @@ pCertificateFile =
)
<*> optional (pScriptWitnessFiles
WitCtxStake
"certificate"
"certificate" Nothing
"the use of the certificate.")
where
helpText = "Filepath of the certificate. This encompasses all \
Expand Down Expand Up @@ -1241,7 +1256,7 @@ pWithdrawal =
)
<*> optional (pScriptWitnessFiles
WitCtxStake
"withdrawal"
"withdrawal" Nothing
"the withdrawal of rewards.")
where
helpText = "The reward withdrawal as StakeAddress+Lovelace where \
Expand Down Expand Up @@ -1696,7 +1711,7 @@ pTxIn =
)
<*> optional (pScriptWitnessFiles
WitCtxTxIn
"txin"
"tx-in" (Just "txin")
"the spending of the transaction input.")

pTxInCollateral :: Parser TxIn
Expand Down Expand Up @@ -1759,7 +1774,7 @@ pMintMultiAsset =
)
<*> some (pScriptWitnessFiles
WitCtxMint
"minting"
"mint" (Just "minting")
"the minting of assets for a particular policy Id.")

where
Expand Down

0 comments on commit ba31337

Please sign in to comment.