Skip to content

Commit

Permalink
Merge pull request #523 from input-output-hk/smelc/output-format->yam…
Browse files Browse the repository at this point in the history
…l-json

--output format becomes --yaml|--json
  • Loading branch information
smelc authored Dec 14, 2023
2 parents e20d931 + 7bb38c3 commit 559b403
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 71 deletions.
18 changes: 10 additions & 8 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1579,15 +1579,17 @@ pGovernanceVoteViewOutputFormat = pViewOutputFormat "governance vote"
-- to view some data (json or yaml). @what@ is the kind of data considered.
pViewOutputFormat :: String -> Parser ViewOutputFormat
pViewOutputFormat kind =
Opt.option (readViewOutputFormat kind) $ mconcat
[ Opt.long "output-format"
, Opt.metavar "STRING"
, Opt.help $ mconcat
[ "Optional ", kind ," view output format. Accepted output formats are \"json\" "
, "and \"yaml\" (default is \"json\")."
]
, Opt.value ViewOutputFormatJson
asum
[ make ViewOutputFormatJson "JSON" "json" Nothing
, make ViewOutputFormatYaml "YAML" "yaml" (Just " Defaults to JSON if unspecified.")
]
where
make format desc flag_ extraHelp =
Opt.flag ViewOutputFormatJson format $ mconcat
[ Opt.help $
"Format " <> kind <> " view output to " <> desc <> "."
<> fromMaybe "" extraHelp
, Opt.long ("output-" <> flag_)]

pMaybeOutputFile :: Parser (Maybe (File content Out))
pMaybeOutputFile =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ hprop_golden_conway_governance_action_view_update_committee_yaml =
actionView <- execCardanoCLI
[ "conway", "governance", "action", "view"
, "--action-file", actionFile
, "--output-format", "yaml"
, "--output-yaml"
]
H.diffVsGoldenFile actionView goldenActionViewFile

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ hprop_golden_governance_governance_vote_view_yaml =
voteViewGold <- H.note "test/cardano-cli-golden/files/golden/governance/vote/voteViewYAML"
voteView <- execCardanoCLI
[ "conway", "governance", "vote", "view"
, "--output-format", "yaml"
, "--output-yaml"
, "--vote-file", voteFile
]

Expand Down
12 changes: 6 additions & 6 deletions cardano-cli/test/cardano-cli-golden/Test/Golden/TxView.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ _hprop_golden_view_byron_yaml =
-- View transaction body
result <-
execCardanoCLI
["transaction", "view", "--tx-body-file", transactionBodyFile, "--output-format", "yaml"]
["transaction", "view", "--tx-body-file", transactionBodyFile, "--output-yaml"]
H.diffVsGoldenFile result "test/cardano-cli-golden/files/golden/byron/transaction-view.out"

-- TODO: Expose command to view byron tx files
Expand Down Expand Up @@ -147,7 +147,7 @@ hprop_golden_view_shelley_yaml = let
-- View transaction body
result <-
execCardanoCLI
["transaction", "view", "--tx-body-file", transactionBodyFile, "--output-format", "yaml"]
["transaction", "view", "--tx-body-file", transactionBodyFile, "--output-yaml"]

H.diffVsGoldenFile result "test/cardano-cli-golden/files/golden/shelley/transaction-view.out"

Expand Down Expand Up @@ -178,7 +178,7 @@ hprop_golden_view_allegra_yaml =
-- View transaction body
result <-
execCardanoCLI
["transaction", "view", "--tx-body-file", transactionBodyFile, "--output-format", "yaml"]
["transaction", "view", "--tx-body-file", transactionBodyFile, "--output-yaml"]
H.diffVsGoldenFile result "test/cardano-cli-golden/files/golden/allegra/transaction-view.out"

hprop_golden_view_mary_yaml :: Property
Expand Down Expand Up @@ -245,7 +245,7 @@ hprop_golden_view_mary_yaml =
-- View transaction body
result <-
execCardanoCLI
["transaction", "view", "--tx-body-file", transactionBodyFile, "--output-format", "yaml"]
["transaction", "view", "--tx-body-file", transactionBodyFile, "--output-yaml"]
H.diffVsGoldenFile result "test/cardano-cli-golden/files/golden/mary/transaction-view.out"

createAlonzoTxBody :: Maybe FilePath -> FilePath -> Integration ()
Expand Down Expand Up @@ -302,7 +302,7 @@ hprop_golden_view_alonzo_yaml =
-- View transaction body
result <-
execCardanoCLI
["transaction", "view", "--tx-body-file", transactionBodyFile, "--output-format", "yaml"]
["transaction", "view", "--tx-body-file", transactionBodyFile, "--output-yaml"]
H.diffVsGoldenFile result "test/cardano-cli-golden/files/golden/alonzo/transaction-view.out"

hprop_golden_view_alonzo_signed_yaml :: Property
Expand All @@ -328,6 +328,6 @@ hprop_golden_view_alonzo_signed_yaml =
-- View transaction body
result <-
execCardanoCLI
["transaction", "view", "--tx-file", transactionFile, "--output-format", "yaml"]
["transaction", "view", "--tx-file", transactionFile, "--output-yaml"]

H.diffVsGoldenFile result (golden </> "signed-transaction-view.out")
24 changes: 13 additions & 11 deletions cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ Usage: cardano-cli shelley transaction txid

Print a transaction identifier.

Usage: cardano-cli shelley transaction view [--output-format STRING]
Usage: cardano-cli shelley transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
Expand Down Expand Up @@ -2323,7 +2323,7 @@ Usage: cardano-cli allegra transaction txid

Print a transaction identifier.

Usage: cardano-cli allegra transaction view [--output-format STRING]
Usage: cardano-cli allegra transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
Expand Down Expand Up @@ -3463,7 +3463,7 @@ Usage: cardano-cli mary transaction txid (--tx-body-file FILE | --tx-file FILE)

Print a transaction identifier.

Usage: cardano-cli mary transaction view [--output-format STRING]
Usage: cardano-cli mary transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
Expand Down Expand Up @@ -4626,7 +4626,7 @@ Usage: cardano-cli alonzo transaction txid

Print a transaction identifier.

Usage: cardano-cli alonzo transaction view [--output-format STRING]
Usage: cardano-cli alonzo transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
Expand Down Expand Up @@ -5811,7 +5811,7 @@ Usage: cardano-cli babbage transaction txid

Print a transaction identifier.

Usage: cardano-cli babbage transaction view [--output-format STRING]
Usage: cardano-cli babbage transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
Expand Down Expand Up @@ -6258,7 +6258,9 @@ Usage: cardano-cli conway governance action create-treasury-withdrawal
Create a treasury withdrawal.

Usage: cardano-cli conway governance action view --action-file FILE
[--output-format STRING]
[ --output-json
| --output-yaml
]
[--out-file FILE]

View a governance action.
Expand Down Expand Up @@ -6399,7 +6401,7 @@ Usage: cardano-cli conway governance vote create (--yes | --no | --abstain)

Vote creation.

Usage: cardano-cli conway governance vote view [--output-format STRING]
Usage: cardano-cli conway governance vote view [--output-json | --output-yaml]
--vote-file FILE
[--out-file FILE]

Expand Down Expand Up @@ -7320,7 +7322,7 @@ Usage: cardano-cli conway transaction txid

Print a transaction identifier.

Usage: cardano-cli conway transaction view [--output-format STRING]
Usage: cardano-cli conway transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
Expand Down Expand Up @@ -8502,7 +8504,7 @@ Usage: cardano-cli latest transaction txid

Print a transaction identifier.

Usage: cardano-cli latest transaction view [--output-format STRING]
Usage: cardano-cli latest transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
Expand Down Expand Up @@ -9540,7 +9542,7 @@ Usage: cardano-cli legacy transaction txid

Print a transaction identifier.

Usage: cardano-cli legacy transaction view [--output-format STRING]
Usage: cardano-cli legacy transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
Expand Down Expand Up @@ -10733,7 +10735,7 @@ Usage: cardano-cli transaction txid (--tx-body-file FILE | --tx-file FILE)

Print a transaction identifier.

Usage: cardano-cli transaction view [--output-format STRING]
Usage: cardano-cli transaction view [--output-json | --output-yaml]
[--out-file FILE]
(--tx-body-file FILE | --tx-file FILE)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: cardano-cli allegra transaction view [--output-format STRING]
Usage: cardano-cli allegra transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
Expand All @@ -7,9 +7,9 @@ Usage: cardano-cli allegra transaction view [--output-format STRING]
Print a transaction.

Available options:
--output-format STRING Optional transaction view output format. Accepted
output formats are "json" and "yaml" (default is
"json").
--output-json Format transaction view output to JSON.
--output-yaml Format transaction view output to YAML. Defaults to
JSON if unspecified.
--out-file FILE Optional output file. Default is to write to stdout.
--tx-body-file FILE Input filepath of the JSON TxBody.
--tx-file FILE Input filepath of the JSON Tx.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: cardano-cli alonzo transaction view [--output-format STRING]
Usage: cardano-cli alonzo transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
Expand All @@ -7,9 +7,9 @@ Usage: cardano-cli alonzo transaction view [--output-format STRING]
Print a transaction.

Available options:
--output-format STRING Optional transaction view output format. Accepted
output formats are "json" and "yaml" (default is
"json").
--output-json Format transaction view output to JSON.
--output-yaml Format transaction view output to YAML. Defaults to
JSON if unspecified.
--out-file FILE Optional output file. Default is to write to stdout.
--tx-body-file FILE Input filepath of the JSON TxBody.
--tx-file FILE Input filepath of the JSON Tx.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: cardano-cli babbage transaction view [--output-format STRING]
Usage: cardano-cli babbage transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
Expand All @@ -7,9 +7,9 @@ Usage: cardano-cli babbage transaction view [--output-format STRING]
Print a transaction.

Available options:
--output-format STRING Optional transaction view output format. Accepted
output formats are "json" and "yaml" (default is
"json").
--output-json Format transaction view output to JSON.
--output-yaml Format transaction view output to YAML. Defaults to
JSON if unspecified.
--out-file FILE Optional output file. Default is to write to stdout.
--tx-body-file FILE Input filepath of the JSON TxBody.
--tx-file FILE Input filepath of the JSON Tx.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
Usage: cardano-cli conway governance action view --action-file FILE
[--output-format STRING]
[ --output-json
| --output-yaml
]
[--out-file FILE]

View a governance action.

Available options:
--action-file FILE Path to action file.
--output-format STRING Optional governance action view output format.
Accepted output formats are "json" and "yaml"
(default is "json").
--output-json Format governance action view output to JSON.
--output-yaml Format governance action view output to YAML.
Defaults to JSON if unspecified.
--out-file FILE Optional output file. Default is to write to stdout.
-h,--help Show this help text
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Usage: cardano-cli conway governance vote view [--output-format STRING]
Usage: cardano-cli conway governance vote view [--output-json | --output-yaml]
--vote-file FILE
[--out-file FILE]

Vote viewing.

Available options:
--output-format STRING Optional governance vote view output format. Accepted
output formats are "json" and "yaml" (default is
"json").
--output-json Format governance vote view output to JSON.
--output-yaml Format governance vote view output to YAML. Defaults
to JSON if unspecified.
--vote-file FILE Input filepath of the vote.
--out-file FILE Optional output file. Default is to write to stdout.
-h,--help Show this help text
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: cardano-cli conway transaction view [--output-format STRING]
Usage: cardano-cli conway transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
Expand All @@ -7,9 +7,9 @@ Usage: cardano-cli conway transaction view [--output-format STRING]
Print a transaction.

Available options:
--output-format STRING Optional transaction view output format. Accepted
output formats are "json" and "yaml" (default is
"json").
--output-json Format transaction view output to JSON.
--output-yaml Format transaction view output to YAML. Defaults to
JSON if unspecified.
--out-file FILE Optional output file. Default is to write to stdout.
--tx-body-file FILE Input filepath of the JSON TxBody.
--tx-file FILE Input filepath of the JSON Tx.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: cardano-cli latest transaction view [--output-format STRING]
Usage: cardano-cli latest transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
Expand All @@ -7,9 +7,9 @@ Usage: cardano-cli latest transaction view [--output-format STRING]
Print a transaction.

Available options:
--output-format STRING Optional transaction view output format. Accepted
output formats are "json" and "yaml" (default is
"json").
--output-json Format transaction view output to JSON.
--output-yaml Format transaction view output to YAML. Defaults to
JSON if unspecified.
--out-file FILE Optional output file. Default is to write to stdout.
--tx-body-file FILE Input filepath of the JSON TxBody.
--tx-file FILE Input filepath of the JSON Tx.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: cardano-cli legacy transaction view [--output-format STRING]
Usage: cardano-cli legacy transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
Expand All @@ -7,9 +7,9 @@ Usage: cardano-cli legacy transaction view [--output-format STRING]
Print a transaction.

Available options:
--output-format STRING Optional transaction view output format. Accepted
output formats are "json" and "yaml" (default is
"json").
--output-json Format transaction view output to JSON.
--output-yaml Format transaction view output to YAML. Defaults to
JSON if unspecified.
--out-file FILE Optional output file. Default is to write to stdout.
--tx-body-file FILE Input filepath of the JSON TxBody.
--tx-file FILE Input filepath of the JSON Tx.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: cardano-cli mary transaction view [--output-format STRING]
Usage: cardano-cli mary transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
Expand All @@ -7,9 +7,9 @@ Usage: cardano-cli mary transaction view [--output-format STRING]
Print a transaction.

Available options:
--output-format STRING Optional transaction view output format. Accepted
output formats are "json" and "yaml" (default is
"json").
--output-json Format transaction view output to JSON.
--output-yaml Format transaction view output to YAML. Defaults to
JSON if unspecified.
--out-file FILE Optional output file. Default is to write to stdout.
--tx-body-file FILE Input filepath of the JSON TxBody.
--tx-file FILE Input filepath of the JSON Tx.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: cardano-cli shelley transaction view [--output-format STRING]
Usage: cardano-cli shelley transaction view [--output-json | --output-yaml]
[--out-file FILE]
( --tx-body-file FILE
| --tx-file FILE
Expand All @@ -7,9 +7,9 @@ Usage: cardano-cli shelley transaction view [--output-format STRING]
Print a transaction.

Available options:
--output-format STRING Optional transaction view output format. Accepted
output formats are "json" and "yaml" (default is
"json").
--output-json Format transaction view output to JSON.
--output-yaml Format transaction view output to YAML. Defaults to
JSON if unspecified.
--out-file FILE Optional output file. Default is to write to stdout.
--tx-body-file FILE Input filepath of the JSON TxBody.
--tx-file FILE Input filepath of the JSON Tx.
Expand Down
Loading

0 comments on commit 559b403

Please sign in to comment.