From 53a7bc4aa00523e0206f074818f026970acf82b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Fri, 10 Jan 2025 11:30:27 +0100 Subject: [PATCH] transaction id: do not tie implementation with default of parser --- .../src/Cardano/CLI/EraBased/Commands/Transaction.hs | 2 +- cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs | 6 ++---- .../src/Cardano/CLI/EraBased/Options/Transaction.hs | 2 +- cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs | 7 ++----- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs index 3405c6e415..f6898c8c30 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs @@ -245,7 +245,7 @@ newtype TransactionHashScriptDataCmdArgs = TransactionHashScriptDataCmdArgs data TransactionTxIdCmdArgs = TransactionTxIdCmdArgs { inputTxBodyOrTxFile :: InputTxBodyOrTxFile - , outputFormat :: !(Maybe OutputFormatJsonOrText) + , outputFormat :: !OutputFormatJsonOrText } deriving Show diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index 208367fc1d..4864b42784 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -1727,10 +1727,8 @@ pOutputFormatJsonOrText kind = -- to write @transaction txid@'s output on standard output. pTxIdOutputFormatJsonOrText :: Parser OutputFormatJsonOrText pTxIdOutputFormatJsonOrText = - asum - [ make OutputFormatJson "JSON" "json" - , make OutputFormatText "TEXT" "text" - ] + asum [make OutputFormatJson "JSON" "json", make OutputFormatText "TEXT" "text"] + <|> pure default_ where default_ = OutputFormatText make format desc flag_ = diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs index b8a3025f57..9dc963024b 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs @@ -379,4 +379,4 @@ pTransactionId = fmap TransactionTxIdCmd $ TransactionTxIdCmdArgs <$> pInputTxOrTxBodyFile - <*> optional pTxIdOutputFormatJsonOrText + <*> pTxIdOutputFormatJsonOrText diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs index 1c3ac5f253..54d63ca3ce 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs @@ -1752,11 +1752,8 @@ runTransactionTxIdCmd liftIO $ case outputFormat of - Just OutputFormatJson -> LBS.putStrLn $ Aeson.encode $ TxSubmissionResult txId - Just OutputFormatText -> BS.putStrLn bsToWrite - Nothing -> - -- Stay compatible with output when there was no --output-format flag - BS.putStrLn bsToWrite + OutputFormatJson -> LBS.putStrLn $ Aeson.encode $ TxSubmissionResult txId + OutputFormatText -> BS.putStrLn bsToWrite -- ---------------------------------------------------------------------------- -- Witness commands