Skip to content

Commit

Permalink
Merge pull request #1017 from IntersectMBO/smelc/drep-id-fixed-flags-…
Browse files Browse the repository at this point in the history
…not-flags-STRING

drep id: have --output-bech32 and --output-hex instead of --output-format STRING
  • Loading branch information
smelc authored Jan 13, 2025
2 parents 5c76870 + 0083603 commit 8e82b71
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 27 deletions.
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

0 comments on commit 8e82b71

Please sign in to comment.