Skip to content

Commit

Permalink
transaction id: do not tie implementation with default of parser
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed Jan 10, 2025
1 parent 12b76f5 commit 53a7bc4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ newtype TransactionHashScriptDataCmdArgs = TransactionHashScriptDataCmdArgs

data TransactionTxIdCmdArgs = TransactionTxIdCmdArgs
{ inputTxBodyOrTxFile :: InputTxBodyOrTxFile
, outputFormat :: !(Maybe OutputFormatJsonOrText)
, outputFormat :: !OutputFormatJsonOrText
}
deriving Show

Expand Down
6 changes: 2 additions & 4 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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_ =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,4 @@ pTransactionId =
fmap TransactionTxIdCmd $
TransactionTxIdCmdArgs
<$> pInputTxOrTxBodyFile
<*> optional pTxIdOutputFormatJsonOrText
<*> pTxIdOutputFormatJsonOrText
7 changes: 2 additions & 5 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 53a7bc4

Please sign in to comment.