From 89664a24725c1798b6a06252acfffdf1dc6ac451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Fri, 10 Jan 2025 10:07:21 +0100 Subject: [PATCH 1/3] drep id: have --output-bech32 and --output-hex instead of --output-format STRING --- .../CLI/EraBased/Options/Governance/DRep.hs | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs index 4f57fb9d03..5f5533687b 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs @@ -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 From 1adc1ad42f3f62f34c69a5f92399f1de316656aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Fri, 10 Jan 2025 10:07:27 +0100 Subject: [PATCH 2/3] Adapt tests --- .../cardano-cli-golden/Test/Golden/Governance/DRep.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/DRep.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/DRep.hs index 7bdb93bdf4..d8956afe66 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/DRep.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/DRep.hs @@ -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 @@ -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 @@ -114,8 +117,7 @@ hprop_golden_governance_drep_id_hex = , "id" , "--drep-verification-key-file" , vkeyFile - , "--output-format" - , "hex" + , "--output-hex" , "--out-file" , idFile ] From 0083603c9b4c80e1e051417b12ac5b3dbb907eda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Fri, 10 Jan 2025 10:07:44 +0100 Subject: [PATCH 3/3] Adapt golden files --- cardano-cli/test/cardano-cli-golden/files/golden/help.cli | 8 +++++--- .../golden/help/compatible_conway_governance_drep_id.cli | 8 +++++--- .../files/golden/help/conway_governance_drep_id.cli | 6 +++--- .../files/golden/help/latest_governance_drep_id.cli | 6 +++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli index 6ea71ec9c0..78f7b97936 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -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. @@ -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. @@ -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. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_conway_governance_drep_id.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_conway_governance_drep_id.cli index 029942854e..57a149e683 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_conway_governance_drep_id.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_conway_governance_drep_id.cli @@ -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. @@ -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 diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_drep_id.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_drep_id.cli index e9c2947bec..c08cc40f8a 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_drep_id.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_drep_id.cli @@ -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. @@ -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 diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_drep_id.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_drep_id.cli index 307f2729ca..c3db20ba3a 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_drep_id.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_drep_id.cli @@ -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. @@ -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