Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drep id: have --output-bech32 and --output-hex instead of --output-format STRING #1017

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,19 @@ pGovernanceDRepKeyIdCmd era = do

pDRepIdOutputFormat :: Parser IdOutputFormat
pDRepIdOutputFormat =
Opt.option readIdOutputFormat $
mconcat
[ Opt.long "output-format"
, Opt.metavar "STRING"
, Opt.help $
mconcat
[ "Optional drep id output format. Accepted output formats are \"hex\" "
, "and \"bech32\" (default is \"bech32\")."
]
, Opt.value IdOutputFormatBech32
]
asum [make IdOutputFormatHex "hex", make IdOutputFormatBech32 "bech32"]
<|> pure default_
where
default_ = IdOutputFormatBech32
make format flag_ =
Opt.flag' format $
mconcat
[ Opt.help $
"Format drep id output as "
<> flag_
<> (if format == default_ then " (the default)." else ".")
, Opt.long ("output-" <> flag_)
]

-- Registration Certificate related

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ hprop_golden_governanceDRepKeyGen =
pure $ showOct (mode .&. 0o777) "" -- we only need the 3 lowest octets here
#endif

-- | Execute me with:
-- @cabal test cardano-cli-golden --test-options '-p "/golden governance drep id bech32/"'@
hprop_golden_governance_drep_id_bech32 :: Property
hprop_golden_governance_drep_id_bech32 =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
Expand All @@ -91,14 +93,15 @@ hprop_golden_governance_drep_id_bech32 =
, "id"
, "--drep-verification-key-file"
, vkeyFile
, "--output-format"
, "bech32"
, "--output-bech32"
, "--out-file"
, idFile
]

H.diffFileVsGoldenFile idFile idGold

-- | Execute me with:
-- @cabal test cardano-cli-golden --test-options '-p "/golden governance drep id hex/"'@
hprop_golden_governance_drep_id_hex :: Property
hprop_golden_governance_drep_id_hex =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
Expand All @@ -114,8 +117,7 @@ hprop_golden_governance_drep_id_hex =
, "id"
, "--drep-verification-key-file"
, vkeyFile
, "--output-format"
, "hex"
, "--output-hex"
, "--out-file"
, idFile
]
Expand Down
8 changes: 5 additions & 3 deletions cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -7089,7 +7089,7 @@ Usage: cardano-cli conway governance drep id
| --drep-verification-key-file FILEPATH
| --drep-key-hash HASH
)
[--output-format STRING]
[--output-hex | --output-bech32]
[--out-file FILEPATH]

Generate a drep id.
Expand Down Expand Up @@ -9110,7 +9110,7 @@ Usage: cardano-cli latest governance drep id
| --drep-verification-key-file FILEPATH
| --drep-key-hash HASH
)
[--output-format STRING]
[--output-hex | --output-bech32]
[--out-file FILEPATH]

Generate a drep id.
Expand Down Expand Up @@ -11733,7 +11733,9 @@ Usage: cardano-cli compatible conway governance drep id
| --drep-verification-key-file FILEPATH
| --drep-key-hash HASH
)
[--output-format STRING]
[ --output-hex
| --output-bech32
]
[--out-file FILEPATH]

Generate a drep id.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Usage: cardano-cli compatible conway governance drep id
| --drep-verification-key-file FILEPATH
| --drep-key-hash HASH
)
[--output-format STRING]
[ --output-hex
| --output-bech32
]
[--out-file FILEPATH]

Generate a drep id.
Expand All @@ -15,7 +17,7 @@ Available options:
Filepath of the DRep verification key.
--drep-key-hash HASH DRep verification key hash (either Bech32-encoded or
hex-encoded).
--output-format STRING Optional drep id output format. Accepted output
formats are "hex" and "bech32" (default is "bech32").
--output-hex Format drep id output as hex.
--output-bech32 Format drep id output as bech32 (the default).
--out-file FILEPATH The output file.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Usage: cardano-cli conway governance drep id
| --drep-verification-key-file FILEPATH
| --drep-key-hash HASH
)
[--output-format STRING]
[--output-hex | --output-bech32]
[--out-file FILEPATH]

Generate a drep id.
Expand All @@ -15,7 +15,7 @@ Available options:
Filepath of the DRep verification key.
--drep-key-hash HASH DRep verification key hash (either Bech32-encoded or
hex-encoded).
--output-format STRING Optional drep id output format. Accepted output
formats are "hex" and "bech32" (default is "bech32").
--output-hex Format drep id output as hex.
--output-bech32 Format drep id output as bech32 (the default).
--out-file FILEPATH The output file.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Usage: cardano-cli latest governance drep id
| --drep-verification-key-file FILEPATH
| --drep-key-hash HASH
)
[--output-format STRING]
[--output-hex | --output-bech32]
[--out-file FILEPATH]

Generate a drep id.
Expand All @@ -15,7 +15,7 @@ Available options:
Filepath of the DRep verification key.
--drep-key-hash HASH DRep verification key hash (either Bech32-encoded or
hex-encoded).
--output-format STRING Optional drep id output format. Accepted output
formats are "hex" and "bech32" (default is "bech32").
--output-hex Format drep id output as hex.
--output-bech32 Format drep id output as bech32 (the default).
--out-file FILEPATH The output file.
-h,--help Show this help text
Loading